5971 lines
235 KiB
Rust
5971 lines
235 KiB
Rust
|
|
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
|
|
/// Contract's functions.
|
|
#[allow(dead_code, unused_imports, unused_variables)]
|
|
pub mod functions {
|
|
use super::INTERNAL_ERR;
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct AcceptTransferOwnership {}
|
|
impl AcceptTransferOwnership {
|
|
const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 184u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for AcceptTransferOwnership {
|
|
const NAME: &'static str = "accept_transfer_ownership";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct AddBasePool {
|
|
pub base_pool: Vec<u8>,
|
|
pub fee_receiver: Vec<u8>,
|
|
pub asset_type: substreams::scalar::BigInt,
|
|
pub implementations: [Vec<u8>; 10usize],
|
|
}
|
|
impl AddBasePool {
|
|
const METHOD_ID: [u8; 4] = [47u8, 192u8, 86u8, 83u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
fee_receiver: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
asset_type: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
implementations: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.asset_type.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
{
|
|
let v = self
|
|
.implementations
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for AddBasePool {
|
|
const NAME: &'static str = "add_base_pool";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct AddExistingMetapools {
|
|
pub pools: [Vec<u8>; 10usize],
|
|
}
|
|
impl AddExistingMetapools {
|
|
const METHOD_ID: [u8; 4] = [219u8, 137u8, 250u8, 188u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pools: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[{
|
|
let v = self
|
|
.pools
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
}]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 AddExistingMetapools {
|
|
const NAME: &'static str = "add_existing_metapools";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for AddExistingMetapools {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct AddTokenToWhitelist {
|
|
pub coin: Vec<u8>,
|
|
pub add: bool,
|
|
}
|
|
impl AddTokenToWhitelist {
|
|
const METHOD_ID: [u8; 4] = [42u8, 145u8, 248u8, 22u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Bool],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
coin: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
add: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)),
|
|
ethabi::Token::Bool(self.add.clone()),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for AddTokenToWhitelist {
|
|
const NAME: &'static str = "add_token_to_whitelist";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Admin {}
|
|
impl Admin {
|
|
const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(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<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Admin {
|
|
const NAME: &'static str = "admin";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Admin {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BasePoolAssets {
|
|
pub arg0: Vec<u8>,
|
|
}
|
|
impl BasePoolAssets {
|
|
const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
arg0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.arg0))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 BasePoolAssets {
|
|
const NAME: &'static str = "base_pool_assets";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for BasePoolAssets {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BasePoolCount {}
|
|
impl BasePoolCount {
|
|
const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 59u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Uint(256usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 BasePoolCount {
|
|
const NAME: &'static str = "base_pool_count";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for BasePoolCount {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BasePoolList {
|
|
pub arg0: substreams::scalar::BigInt,
|
|
}
|
|
impl BasePoolList {
|
|
const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values =
|
|
ethabi::decode(&[ethabi::ParamType::Uint(256usize)], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
arg0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.arg0.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for BasePoolList {
|
|
const NAME: &'static str = "base_pool_list";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for BasePoolList {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BatchSetPoolAssetType {
|
|
pub pools: [Vec<u8>; 32usize],
|
|
pub asset_types: [substreams::scalar::BigInt; 32usize],
|
|
}
|
|
impl BatchSetPoolAssetType {
|
|
const METHOD_ID: [u8; 4] = [117u8, 66u8, 240u8, 120u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 32usize),
|
|
ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
32usize,
|
|
),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pools: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
asset_types: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
{
|
|
let v = self
|
|
.pools
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
{
|
|
let v = self
|
|
.asset_types
|
|
.iter()
|
|
.map(|inner| {
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match inner.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
))
|
|
})
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for BatchSetPoolAssetType {
|
|
const NAME: &'static str = "batch_set_pool_asset_type";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct CommitTransferOwnership {
|
|
pub addr: Vec<u8>,
|
|
}
|
|
impl CommitTransferOwnership {
|
|
const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
addr: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.addr))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for CommitTransferOwnership {
|
|
const NAME: &'static str = "commit_transfer_ownership";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct ConvertMetapoolFees {}
|
|
impl ConvertMetapoolFees {
|
|
const METHOD_ID: [u8; 4] = [188u8, 201u8, 129u8, 210u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 ConvertMetapoolFees {
|
|
const NAME: &'static str = "convert_metapool_fees";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for ConvertMetapoolFees {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployGauge {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl DeployGauge {
|
|
const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployGauge {
|
|
const NAME: &'static str = "deploy_gauge";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployGauge {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployMetapool1 {
|
|
pub base_pool: Vec<u8>,
|
|
pub name: String,
|
|
pub symbol: String,
|
|
pub coin: Vec<u8>,
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
}
|
|
impl DeployMetapool1 {
|
|
const METHOD_ID: [u8; 4] = [227u8, 57u8, 235u8, 79u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
name: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
symbol: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
coin: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)),
|
|
ethabi::Token::String(self.name.clone()),
|
|
ethabi::Token::String(self.symbol.clone()),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.a.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.fee.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployMetapool1 {
|
|
const NAME: &'static str = "deploy_metapool1";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployMetapool1 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployMetapool2 {
|
|
pub base_pool: Vec<u8>,
|
|
pub name: String,
|
|
pub symbol: String,
|
|
pub coin: Vec<u8>,
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
pub implementation_idx: substreams::scalar::BigInt,
|
|
}
|
|
impl DeployMetapool2 {
|
|
const METHOD_ID: [u8; 4] = [222u8, 127u8, 227u8, 191u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
name: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
symbol: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
coin: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
implementation_idx: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)),
|
|
ethabi::Token::String(self.name.clone()),
|
|
ethabi::Token::String(self.symbol.clone()),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.a.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.fee.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self
|
|
.implementation_idx
|
|
.clone()
|
|
.to_bytes_be()
|
|
{
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployMetapool2 {
|
|
const NAME: &'static str = "deploy_metapool2";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployMetapool2 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployPlainPool1 {
|
|
pub name: String,
|
|
pub symbol: String,
|
|
pub coins: [Vec<u8>; 4usize],
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
}
|
|
impl DeployPlainPool1 {
|
|
const METHOD_ID: [u8; 4] = [205u8, 65u8, 155u8, 181u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
name: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
symbol: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
coins: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::String(self.name.clone()),
|
|
ethabi::Token::String(self.symbol.clone()),
|
|
{
|
|
let v = self
|
|
.coins
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.a.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.fee.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployPlainPool1 {
|
|
const NAME: &'static str = "deploy_plain_pool1";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployPlainPool1 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployPlainPool2 {
|
|
pub name: String,
|
|
pub symbol: String,
|
|
pub coins: [Vec<u8>; 4usize],
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
pub asset_type: substreams::scalar::BigInt,
|
|
}
|
|
impl DeployPlainPool2 {
|
|
const METHOD_ID: [u8; 4] = [92u8, 22u8, 72u8, 123u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
name: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
symbol: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
coins: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
asset_type: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::String(self.name.clone()),
|
|
ethabi::Token::String(self.symbol.clone()),
|
|
{
|
|
let v = self
|
|
.coins
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.a.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.fee.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.asset_type.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployPlainPool2 {
|
|
const NAME: &'static str = "deploy_plain_pool2";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployPlainPool2 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DeployPlainPool3 {
|
|
pub name: String,
|
|
pub symbol: String,
|
|
pub coins: [Vec<u8>; 4usize],
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
pub asset_type: substreams::scalar::BigInt,
|
|
pub implementation_idx: substreams::scalar::BigInt,
|
|
}
|
|
impl DeployPlainPool3 {
|
|
const METHOD_ID: [u8; 4] = [82u8, 242u8, 219u8, 105u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
name: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
symbol: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
coins: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
asset_type: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
implementation_idx: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::String(self.name.clone()),
|
|
ethabi::Token::String(self.symbol.clone()),
|
|
{
|
|
let v = self
|
|
.coins
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.a.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.fee.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.asset_type.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self
|
|
.implementation_idx
|
|
.clone()
|
|
.to_bytes_be()
|
|
{
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DeployPlainPool3 {
|
|
const NAME: &'static str = "deploy_plain_pool3";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for DeployPlainPool3 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct FindPoolForCoins1 {
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl FindPoolForCoins1 {
|
|
const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
from: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.from)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for FindPoolForCoins1 {
|
|
const NAME: &'static str = "find_pool_for_coins1";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for FindPoolForCoins1 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct FindPoolForCoins2 {
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
pub i: substreams::scalar::BigInt,
|
|
}
|
|
impl FindPoolForCoins2 {
|
|
const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
from: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
i: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.from)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.i.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for FindPoolForCoins2 {
|
|
const NAME: &'static str = "find_pool_for_coins2";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for FindPoolForCoins2 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct FutureAdmin {}
|
|
impl FutureAdmin {
|
|
const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(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<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for FutureAdmin {
|
|
const NAME: &'static str = "future_admin";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for FutureAdmin {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GaugeImplementation {}
|
|
impl GaugeImplementation {
|
|
const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(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<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GaugeImplementation {
|
|
const NAME: &'static str = "gauge_implementation";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GaugeImplementation {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetA {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetA {
|
|
const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Uint(256usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 GetA {
|
|
const NAME: &'static str = "get_A";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for GetA {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetAdminBalances {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetAdminBalances {
|
|
const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
4usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 4usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetAdminBalances {
|
|
const NAME: &'static str = "get_admin_balances";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]>
|
|
for GetAdminBalances
|
|
{
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetBalances {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetBalances {
|
|
const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
4usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 4usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetBalances {
|
|
const NAME: &'static str = "get_balances";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> for GetBalances {
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetBasePool {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetBasePool {
|
|
const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 221u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetBasePool {
|
|
const NAME: &'static str = "get_base_pool";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetBasePool {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetCoinIndices {
|
|
pub pool: Vec<u8>,
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl GetCoinIndices {
|
|
const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
from: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.from)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String>
|
|
{
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String>
|
|
{
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Int(128usize),
|
|
ethabi::ParamType::Int(128usize),
|
|
ethabi::ParamType::Bool,
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<u8>,
|
|
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetCoinIndices {
|
|
const NAME: &'static str = "get_coin_indices";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl
|
|
substreams_ethereum::rpc::RPCDecodable<(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
)> for GetCoinIndices
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String>
|
|
{
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetCoins {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetCoins {
|
|
const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[Vec<u8>; 4usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[Vec<u8>; 4usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[Vec<u8>; 4usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetCoins {
|
|
const NAME: &'static str = "get_coins";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[Vec<u8>; 4usize]> for GetCoins {
|
|
fn output(data: &[u8]) -> Result<[Vec<u8>; 4usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetDecimals {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetDecimals {
|
|
const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
4usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 4usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetDecimals {
|
|
const NAME: &'static str = "get_decimals";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> for GetDecimals {
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetFeeReceiver {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetFeeReceiver {
|
|
const METHOD_ID: [u8; 4] = [21u8, 74u8, 168u8, 245u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetFeeReceiver {
|
|
const NAME: &'static str = "get_fee_receiver";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetFeeReceiver {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetFees {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetFees {
|
|
const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<u8>,
|
|
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetFees {
|
|
const NAME: &'static str = "get_fees";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl
|
|
substreams_ethereum::rpc::RPCDecodable<(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
)> for GetFees
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetGauge {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetGauge {
|
|
const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetGauge {
|
|
const NAME: &'static str = "get_gauge";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetGauge {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetImplementationAddress {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetImplementationAddress {
|
|
const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetImplementationAddress {
|
|
const NAME: &'static str = "get_implementation_address";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetImplementationAddress {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMetaNCoins {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetMetaNCoins {
|
|
const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<u8>,
|
|
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetMetaNCoins {
|
|
const NAME: &'static str = "get_meta_n_coins";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl
|
|
substreams_ethereum::rpc::RPCDecodable<(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
)> for GetMetaNCoins
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMetapoolRates {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetMetapoolRates {
|
|
const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 2usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
2usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 2usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetMetapoolRates {
|
|
const NAME: &'static str = "get_metapool_rates";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]>
|
|
for GetMetapoolRates
|
|
{
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetNCoins {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetNCoins {
|
|
const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 241u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Uint(256usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 GetNCoins {
|
|
const NAME: &'static str = "get_n_coins";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for GetNCoins {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetPoolAssetType {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetPoolAssetType {
|
|
const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Uint(256usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 GetPoolAssetType {
|
|
const NAME: &'static str = "get_pool_asset_type";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for GetPoolAssetType {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetUnderlyingBalances {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetUnderlyingBalances {
|
|
const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 81u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
8usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 8usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetUnderlyingBalances {
|
|
const NAME: &'static str = "get_underlying_balances";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]>
|
|
for GetUnderlyingBalances
|
|
{
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetUnderlyingCoins {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetUnderlyingCoins {
|
|
const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[Vec<u8>; 8usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[Vec<u8>; 8usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[Vec<u8>; 8usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetUnderlyingCoins {
|
|
const NAME: &'static str = "get_underlying_coins";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[Vec<u8>; 8usize]> for GetUnderlyingCoins {
|
|
fn output(data: &[u8]) -> Result<[Vec<u8>; 8usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetUnderlyingDecimals {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl GetUnderlyingDecimals {
|
|
const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 241u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
8usize,
|
|
)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[substreams::scalar::BigInt; 8usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetUnderlyingDecimals {
|
|
const NAME: &'static str = "get_underlying_decimals";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]>
|
|
for GetUnderlyingDecimals
|
|
{
|
|
fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct IsMeta {
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl IsMeta {
|
|
const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 IsMeta {
|
|
const NAME: &'static str = "is_meta";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for IsMeta {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Manager {}
|
|
impl Manager {
|
|
const METHOD_ID: [u8; 4] = [72u8, 28u8, 106u8, 117u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(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<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Manager {
|
|
const NAME: &'static str = "manager";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Manager {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct MetapoolImplementations {
|
|
pub base_pool: Vec<u8>,
|
|
}
|
|
impl MetapoolImplementations {
|
|
const METHOD_ID: [u8; 4] = [151u8, 15u8, 163u8, 243u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(
|
|
&self.base_pool,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[Vec<u8>; 10usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[Vec<u8>; 10usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut iter = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[Vec<u8>; 10usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for MetapoolImplementations {
|
|
const NAME: &'static str = "metapool_implementations";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[Vec<u8>; 10usize]> for MetapoolImplementations {
|
|
fn output(data: &[u8]) -> Result<[Vec<u8>; 10usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PlainImplementations {
|
|
pub arg0: substreams::scalar::BigInt,
|
|
pub arg1: substreams::scalar::BigInt,
|
|
}
|
|
impl PlainImplementations {
|
|
const METHOD_ID: [u8; 4] = [49u8, 164u8, 248u8, 101u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize)],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
arg0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
arg1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.arg0.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.arg1.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for PlainImplementations {
|
|
const NAME: &'static str = "plain_implementations";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for PlainImplementations {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PlainWhitelist {
|
|
pub arg0: Vec<u8>,
|
|
}
|
|
impl PlainWhitelist {
|
|
const METHOD_ID: [u8; 4] = [222u8, 122u8, 248u8, 46u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
arg0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data =
|
|
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.arg0))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 PlainWhitelist {
|
|
const NAME: &'static str = "plain_whitelist";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for PlainWhitelist {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PoolCount {}
|
|
impl PoolCount {
|
|
const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 58u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Uint(256usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<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 PoolCount {
|
|
const NAME: &'static str = "pool_count";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for PoolCount {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PoolList {
|
|
pub arg0: substreams::scalar::BigInt,
|
|
}
|
|
impl PoolList {
|
|
const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values =
|
|
ethabi::decode(&[ethabi::ParamType::Uint(256usize)], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
arg0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.arg0.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec())
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for PoolList {
|
|
const NAME: &'static str = "pool_list";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for PoolList {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct SetFeeReceiver {
|
|
pub base_pool: Vec<u8>,
|
|
pub fee_receiver: Vec<u8>,
|
|
}
|
|
impl SetFeeReceiver {
|
|
const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
fee_receiver: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for SetFeeReceiver {
|
|
const NAME: &'static str = "set_fee_receiver";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct SetGaugeImplementation {
|
|
pub gauge_implementation: Vec<u8>,
|
|
}
|
|
impl SetGaugeImplementation {
|
|
const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
gauge_implementation: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(
|
|
&self.gauge_implementation,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for SetGaugeImplementation {
|
|
const NAME: &'static str = "set_gauge_implementation";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct SetManager {
|
|
pub manager: Vec<u8>,
|
|
}
|
|
impl SetManager {
|
|
const METHOD_ID: [u8; 4] = [154u8, 236u8, 232u8, 62u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
manager: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(
|
|
&self.manager,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for SetManager {
|
|
const NAME: &'static str = "set_manager";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct SetMetapoolImplementations {
|
|
pub base_pool: Vec<u8>,
|
|
pub implementations: [Vec<u8>; 10usize],
|
|
}
|
|
impl SetMetapoolImplementations {
|
|
const METHOD_ID: [u8; 4] = [203u8, 149u8, 107u8, 70u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
implementations: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)),
|
|
{
|
|
let v = self
|
|
.implementations
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for SetMetapoolImplementations {
|
|
const NAME: &'static str = "set_metapool_implementations";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct SetPlainImplementations {
|
|
pub n_coins: substreams::scalar::BigInt,
|
|
pub implementations: [Vec<u8>; 10usize],
|
|
}
|
|
impl SetPlainImplementations {
|
|
const METHOD_ID: [u8; 4] = [157u8, 219u8, 244u8, 185u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
n_coins: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
implementations: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.n_coins.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
{
|
|
let v = self
|
|
.implementations
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
|
.collect();
|
|
ethabi::Token::FixedArray(v)
|
|
},
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for SetPlainImplementations {
|
|
const NAME: &'static str = "set_plain_implementations";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
}
|
|
/// Contract's events.
|
|
#[allow(dead_code, unused_imports, unused_variables)]
|
|
pub mod events {
|
|
use super::INTERNAL_ERR;
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BasePoolAdded {
|
|
pub base_pool: Vec<u8>,
|
|
}
|
|
impl BasePoolAdded {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
204u8, 106u8, 253u8, 254u8, 199u8, 157u8, 166u8, 190u8, 8u8, 20u8, 46u8, 206u8, 226u8,
|
|
92u8, 241u8, 75u8, 102u8, 89u8, 97u8, 226u8, 93u8, 48u8, 216u8, 235u8, 164u8, 89u8,
|
|
89u8, 190u8, 149u8, 71u8, 99u8, 95u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 32usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], log.data.as_ref())
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for BasePoolAdded {
|
|
const NAME: &'static str = "BasePoolAdded";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct LiquidityGaugeDeployed {
|
|
pub pool: Vec<u8>,
|
|
pub gauge: Vec<u8>,
|
|
}
|
|
impl LiquidityGaugeDeployed {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8,
|
|
98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8,
|
|
246u8, 219u8, 252u8, 90u8, 171u8, 59u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 64usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Address],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
gauge: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for LiquidityGaugeDeployed {
|
|
const NAME: &'static str = "LiquidityGaugeDeployed";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct MetaPoolDeployed {
|
|
pub coin: Vec<u8>,
|
|
pub base_pool: Vec<u8>,
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
pub deployer: Vec<u8>,
|
|
}
|
|
impl MetaPoolDeployed {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
1u8, 243u8, 28u8, 210u8, 171u8, 222u8, 180u8, 229u8, 225u8, 11u8, 165u8, 0u8, 242u8,
|
|
219u8, 15u8, 147u8, 125u8, 158u8, 140u8, 115u8, 90u8, 176u8, 70u8, 129u8, 146u8, 84u8,
|
|
65u8, 180u8, 234u8, 55u8, 237u8, 165u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 160usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Address,
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
coin: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
base_pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
deployer: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for MetaPoolDeployed {
|
|
const NAME: &'static str = "MetaPoolDeployed";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PlainPoolDeployed {
|
|
pub coins: [Vec<u8>; 4usize],
|
|
pub a: substreams::scalar::BigInt,
|
|
pub fee: substreams::scalar::BigInt,
|
|
pub deployer: Vec<u8>,
|
|
pub pool: Vec<u8>,
|
|
}
|
|
impl PlainPoolDeployed {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
184u8, 246u8, 151u8, 45u8, 110u8, 86u8, 210u8, 28u8, 71u8, 98u8, 30u8, 253u8, 127u8,
|
|
2u8, 254u8, 104u8, 240u8, 122u8, 23u8, 201u8, 153u8, 196u8, 34u8, 69u8, 179u8, 171u8,
|
|
211u8, 0u8, 243u8, 77u8, 97u8, 235u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 256usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
coins: {
|
|
let mut iter = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec()
|
|
});
|
|
[
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
iter.next().expect(INTERNAL_ERR),
|
|
]
|
|
},
|
|
a: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
fee: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
deployer: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
pool: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for PlainPoolDeployed {
|
|
const NAME: &'static str = "PlainPoolDeployed";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
}
|