* fix: add `balance_owner` attribute for ekubo_v2 components * refactor: rename `ekubo` into `ekubo-v2` * refactor: freeze `substreams-helper` version in ekubo V2 module * docs: improve integration test comment * docs: add TODO to remove `balance_owner` in favor of `AccountBalances` --------- Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
3897 lines
155 KiB
Rust
3897 lines
155 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 AccumulateAsFees {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub amount0: substreams::scalar::BigInt,
|
|
pub amount1: substreams::scalar::BigInt,
|
|
}
|
|
impl AccumulateAsFees {
|
|
const METHOD_ID: [u8; 4] = [233u8, 100u8, 4u8, 248u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Uint(128usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
amount0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount0.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount1.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for AccumulateAsFees {
|
|
const NAME: &'static str = "accumulateAsFees";
|
|
fn match_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 CancelOwnershipHandover {}
|
|
impl CancelOwnershipHandover {
|
|
const METHOD_ID: [u8; 4] = [84u8, 209u8, 241u8, 61u8];
|
|
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 CancelOwnershipHandover {
|
|
const NAME: &'static str = "cancelOwnershipHandover";
|
|
fn match_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 CollectFees {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub salt: [u8; 32usize],
|
|
pub bounds: (substreams::scalar::BigInt, substreams::scalar::BigInt),
|
|
}
|
|
impl CollectFees {
|
|
const METHOD_ID: [u8; 4] = [100u8, 94u8, 201u8, 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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
]),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
salt: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
bounds: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
ethabi::Token::FixedBytes(self.salt.as_ref().to_vec()),
|
|
ethabi::Token::Tuple(vec![
|
|
{
|
|
let non_full_signed_bytes = self.bounds.0.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
{
|
|
let non_full_signed_bytes = self.bounds.1.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
]),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<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 CollectFees {
|
|
const NAME: &'static str = "collectFees";
|
|
fn match_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 CollectFees
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct CompleteOwnershipHandover {
|
|
pub pending_owner: Vec<u8>,
|
|
}
|
|
impl CompleteOwnershipHandover {
|
|
const METHOD_ID: [u8; 4] = [240u8, 78u8, 40u8, 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 {
|
|
pending_owner: 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.pending_owner,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for CompleteOwnershipHandover {
|
|
const NAME: &'static str = "completeOwnershipHandover";
|
|
fn match_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 Forward {
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Forward {
|
|
const METHOD_ID: [u8; 4] = [16u8, 30u8, 137u8, 82u8];
|
|
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 {
|
|
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.to))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Forward {
|
|
const NAME: &'static str = "forward";
|
|
fn match_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 GetPoolFeesPerLiquidityInside {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub bounds: (substreams::scalar::BigInt, substreams::scalar::BigInt),
|
|
}
|
|
impl GetPoolFeesPerLiquidityInside {
|
|
const METHOD_ID: [u8; 4] = [5u8, 215u8, 230u8, 148u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
]),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
bounds: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
ethabi::Token::Tuple(vec![
|
|
{
|
|
let non_full_signed_bytes = self.bounds.0.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
{
|
|
let non_full_signed_bytes = self.bounds.1.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
]),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), 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::Tuple(vec![
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
])],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::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 GetPoolFeesPerLiquidityInside {
|
|
const NAME: &'static str = "getPoolFeesPerLiquidityInside";
|
|
fn match_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 GetPoolFeesPerLiquidityInside
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct InitializePool {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub tick: substreams::scalar::BigInt,
|
|
}
|
|
impl InitializePool {
|
|
const METHOD_ID: [u8; 4] = [192u8, 83u8, 2u8, 68u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Int(32usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
tick: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
{
|
|
let non_full_signed_bytes = self.tick.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, 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(96usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::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 InitializePool {
|
|
const NAME: &'static str = "initializePool";
|
|
fn match_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 InitializePool {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Load {
|
|
pub token: Vec<u8>,
|
|
pub salt: [u8; 32usize],
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl Load {
|
|
const METHOD_ID: [u8; 4] = [88u8, 53u8, 42u8, 97u8];
|
|
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::FixedBytes(32usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
salt: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token)),
|
|
ethabi::Token::FixedBytes(self.salt.as_ref().to_vec()),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Load {
|
|
const NAME: &'static str = "load";
|
|
fn match_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 Lock {}
|
|
impl Lock {
|
|
const METHOD_ID: [u8; 4] = [248u8, 61u8, 8u8, 186u8];
|
|
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 Lock {
|
|
const NAME: &'static str = "lock";
|
|
fn match_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 NextInitializedTick {
|
|
pub pool_id: [u8; 32usize],
|
|
pub from_tick: substreams::scalar::BigInt,
|
|
pub tick_spacing: substreams::scalar::BigInt,
|
|
pub skip_ahead: substreams::scalar::BigInt,
|
|
}
|
|
impl NextInitializedTick {
|
|
const METHOD_ID: [u8; 4] = [102u8, 224u8, 100u8, 168u8];
|
|
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::FixedBytes(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Uint(32usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
from_tick: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
tick_spacing: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
skip_ahead: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(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::FixedBytes(self.pool_id.as_ref().to_vec()),
|
|
{
|
|
let non_full_signed_bytes = self.from_tick.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.tick_spacing.clone().to_bytes_be() {
|
|
(num_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.skip_ahead.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(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, bool), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<(substreams::scalar::BigInt, bool), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Int(32usize), ethabi::ParamType::Bool],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_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, 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 NextInitializedTick {
|
|
const NAME: &'static str = "nextInitializedTick";
|
|
fn match_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, bool)>
|
|
for NextInitializedTick
|
|
{
|
|
fn output(data: &[u8]) -> Result<(substreams::scalar::BigInt, bool), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Owner {}
|
|
impl Owner {
|
|
const METHOD_ID: [u8; 4] = [141u8, 165u8, 203u8, 91u8];
|
|
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<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 Owner {
|
|
const NAME: &'static str = "owner";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Owner {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct OwnershipHandoverExpiresAt {
|
|
pub pending_owner: Vec<u8>,
|
|
}
|
|
impl OwnershipHandoverExpiresAt {
|
|
const METHOD_ID: [u8; 4] = [254u8, 232u8, 28u8, 244u8];
|
|
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 {
|
|
pending_owner: 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.pending_owner,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<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 OwnershipHandoverExpiresAt {
|
|
const NAME: &'static str = "ownershipHandoverExpiresAt";
|
|
fn match_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 OwnershipHandoverExpiresAt
|
|
{
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Pay {
|
|
pub token: Vec<u8>,
|
|
}
|
|
impl Pay {
|
|
const METHOD_ID: [u8; 4] = [12u8, 17u8, 222u8, 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 {
|
|
token: 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.token))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<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(128usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<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 Pay {
|
|
const NAME: &'static str = "pay";
|
|
fn match_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 Pay {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PrevInitializedTick {
|
|
pub pool_id: [u8; 32usize],
|
|
pub from_tick: substreams::scalar::BigInt,
|
|
pub tick_spacing: substreams::scalar::BigInt,
|
|
pub skip_ahead: substreams::scalar::BigInt,
|
|
}
|
|
impl PrevInitializedTick {
|
|
const METHOD_ID: [u8; 4] = [14u8, 127u8, 38u8, 57u8];
|
|
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::FixedBytes(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Uint(32usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
from_tick: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
tick_spacing: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
skip_ahead: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(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::FixedBytes(self.pool_id.as_ref().to_vec()),
|
|
{
|
|
let non_full_signed_bytes = self.from_tick.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.tick_spacing.clone().to_bytes_be() {
|
|
(num_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.skip_ahead.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(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, bool), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<(substreams::scalar::BigInt, bool), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Int(32usize), ethabi::ParamType::Bool],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_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, 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 PrevInitializedTick {
|
|
const NAME: &'static str = "prevInitializedTick";
|
|
fn match_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, bool)>
|
|
for PrevInitializedTick
|
|
{
|
|
fn output(data: &[u8]) -> Result<(substreams::scalar::BigInt, bool), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct RegisterExtension {
|
|
pub expected_call_points: (bool, bool, bool, bool, bool, bool, bool, bool),
|
|
}
|
|
impl RegisterExtension {
|
|
const METHOD_ID: [u8; 4] = [222u8, 111u8, 147u8, 95u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool,
|
|
])],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
expected_call_points: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[3usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[4usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[5usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[6usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
tuple_elements[7usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Bool(self.expected_call_points.0.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.1.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.2.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.3.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.4.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.5.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.6.clone()),
|
|
ethabi::Token::Bool(self.expected_call_points.7.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 RegisterExtension {
|
|
const NAME: &'static str = "registerExtension";
|
|
fn match_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 RenounceOwnership {}
|
|
impl RenounceOwnership {
|
|
const METHOD_ID: [u8; 4] = [113u8, 80u8, 24u8, 166u8];
|
|
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 RenounceOwnership {
|
|
const NAME: &'static str = "renounceOwnership";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct RequestOwnershipHandover {}
|
|
impl RequestOwnershipHandover {
|
|
const METHOD_ID: [u8; 4] = [37u8, 105u8, 41u8, 98u8];
|
|
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 RequestOwnershipHandover {
|
|
const NAME: &'static str = "requestOwnershipHandover";
|
|
fn match_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 Save {
|
|
pub owner: Vec<u8>,
|
|
pub token: Vec<u8>,
|
|
pub salt: [u8; 32usize],
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl Save {
|
|
const METHOD_ID: [u8; 4] = [133u8, 50u8, 209u8, 57u8];
|
|
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::FixedBytes(32usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
owner: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
salt: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token)),
|
|
ethabi::Token::FixedBytes(self.salt.as_ref().to_vec()),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Save {
|
|
const NAME: &'static str = "save";
|
|
fn match_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 Sload {
|
|
pub slot: [u8; 32usize],
|
|
}
|
|
impl Sload {
|
|
const METHOD_ID: [u8; 4] = [244u8, 145u8, 10u8, 115u8];
|
|
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::FixedBytes(32usize)], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
slot: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::FixedBytes(self.slot.as_ref().to_vec())]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[u8; 32usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
let mut values =
|
|
ethabi::decode(&[ethabi::ParamType::FixedBytes(32usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[u8; 32usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Sload {
|
|
const NAME: &'static str = "sload";
|
|
fn match_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<[u8; 32usize]> for Sload {
|
|
fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Swap {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub params: (
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
}
|
|
impl Swap {
|
|
const METHOD_ID: [u8; 4] = [213u8, 86u8, 155u8, 177u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(128usize),
|
|
ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Uint(96usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
]),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
params: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[3usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
ethabi::Token::Tuple(vec![
|
|
{
|
|
let non_full_signed_bytes = self.params.0.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
ethabi::Token::Bool(self.params.1.clone()),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.params.2.clone().to_bytes_be() {
|
|
(num_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.params.3.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Int(128usize), ethabi::ParamType::Int(128usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<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 Swap {
|
|
const NAME: &'static str = "swap";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl
|
|
substreams_ethereum::rpc::RPCDecodable<(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
)> for Swap
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Tload {
|
|
pub slot: [u8; 32usize],
|
|
}
|
|
impl Tload {
|
|
const METHOD_ID: [u8; 4] = [189u8, 46u8, 88u8, 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::FixedBytes(32usize)], maybe_data.unwrap())
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
slot: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[ethabi::Token::FixedBytes(self.slot.as_ref().to_vec())]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[u8; 32usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
let mut values =
|
|
ethabi::decode(&[ethabi::ParamType::FixedBytes(32usize)], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[u8; 32usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses
|
|
.get(0)
|
|
.expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME,
|
|
err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Tload {
|
|
const NAME: &'static str = "tload";
|
|
fn match_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<[u8; 32usize]> for Tload {
|
|
fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct TransferOwnership {
|
|
pub new_owner: Vec<u8>,
|
|
}
|
|
impl TransferOwnership {
|
|
const METHOD_ID: [u8; 4] = [242u8, 253u8, 227u8, 139u8];
|
|
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 {
|
|
new_owner: 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.new_owner,
|
|
))]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for TransferOwnership {
|
|
const NAME: &'static str = "transferOwnership";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct UpdatePosition {
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub params: (
|
|
[u8; 32usize],
|
|
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
|
substreams::scalar::BigInt,
|
|
),
|
|
}
|
|
impl UpdatePosition {
|
|
const METHOD_ID: [u8; 4] = [85u8, 244u8, 141u8, 1u8];
|
|
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::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
]),
|
|
ethabi::ParamType::Int(128usize),
|
|
]),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
params: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[0usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
{
|
|
let tuple_elements = tuple_elements[1usize]
|
|
.clone()
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.pool_key.1)),
|
|
ethabi::Token::FixedBytes(self.pool_key.2.as_ref().to_vec()),
|
|
]),
|
|
ethabi::Token::Tuple(vec![
|
|
ethabi::Token::FixedBytes(self.params.0.as_ref().to_vec()),
|
|
ethabi::Token::Tuple(vec![
|
|
{
|
|
let non_full_signed_bytes = self.params.1 .0.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(
|
|
full_signed_bytes.as_ref(),
|
|
))
|
|
},
|
|
{
|
|
let non_full_signed_bytes = self.params.1 .1.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(
|
|
full_signed_bytes.as_ref(),
|
|
))
|
|
},
|
|
]),
|
|
{
|
|
let non_full_signed_bytes = self.params.2.to_signed_bytes_be();
|
|
let full_signed_bytes_init =
|
|
if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 };
|
|
let mut full_signed_bytes = [full_signed_bytes_init as u8; 32];
|
|
non_full_signed_bytes
|
|
.into_iter()
|
|
.rev()
|
|
.enumerate()
|
|
.for_each(|(i, byte)| full_signed_bytes[31 - i] = byte);
|
|
ethabi::Token::Int(ethabi::Int::from_big_endian(full_signed_bytes.as_ref()))
|
|
},
|
|
]),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Int(128usize), ethabi::ParamType::Int(128usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<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 UpdatePosition {
|
|
const NAME: &'static str = "updatePosition";
|
|
fn match_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 UpdatePosition
|
|
{
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Withdraw {
|
|
pub token: Vec<u8>,
|
|
pub recipient: Vec<u8>,
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl Withdraw {
|
|
const METHOD_ID: [u8; 4] = [3u8, 166u8, 90u8, 182u8];
|
|
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(128usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
recipient: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.recipient)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Withdraw {
|
|
const NAME: &'static str = "withdraw";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct WithdrawProtocolFees {
|
|
pub recipient: Vec<u8>,
|
|
pub token: Vec<u8>,
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl WithdrawProtocolFees {
|
|
const METHOD_ID: [u8; 4] = [61u8, 81u8, 37u8, 20u8];
|
|
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 {
|
|
recipient: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.recipient)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token)),
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
|
match self.amount.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
)),
|
|
]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for WithdrawProtocolFees {
|
|
const NAME: &'static str = "withdrawProtocolFees";
|
|
fn match_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 ExtensionRegistered {
|
|
pub extension: Vec<u8>,
|
|
}
|
|
impl ExtensionRegistered {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
236u8, 18u8, 86u8, 38u8, 110u8, 71u8, 10u8, 187u8, 134u8, 134u8, 32u8, 200u8, 81u8,
|
|
246u8, 189u8, 226u8, 163u8, 255u8, 96u8, 37u8, 73u8, 220u8, 173u8, 49u8, 138u8, 185u8,
|
|
204u8, 252u8, 178u8, 151u8, 127u8, 20u8,
|
|
];
|
|
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 {
|
|
extension: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for ExtensionRegistered {
|
|
const NAME: &'static str = "ExtensionRegistered";
|
|
fn match_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 FeesAccumulated {
|
|
pub pool_id: [u8; 32usize],
|
|
pub amount0: substreams::scalar::BigInt,
|
|
pub amount1: substreams::scalar::BigInt,
|
|
}
|
|
impl FeesAccumulated {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
247u8, 224u8, 80u8, 216u8, 102u8, 119u8, 72u8, 32u8, 216u8, 26u8, 134u8, 202u8, 103u8,
|
|
111u8, 58u8, 254u8, 123u8, 199u8, 38u8, 3u8, 238u8, 137u8, 63u8, 130u8, 233u8, 156u8,
|
|
8u8, 251u8, 222u8, 57u8, 175u8, 108u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 96usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
amount0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for FeesAccumulated {
|
|
const NAME: &'static str = "FeesAccumulated";
|
|
fn match_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 LoadedBalance {
|
|
pub owner: Vec<u8>,
|
|
pub token: Vec<u8>,
|
|
pub salt: [u8; 32usize],
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl LoadedBalance {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
233u8, 93u8, 71u8, 15u8, 173u8, 181u8, 253u8, 214u8, 26u8, 9u8, 226u8, 252u8, 152u8,
|
|
201u8, 140u8, 105u8, 92u8, 17u8, 12u8, 150u8, 63u8, 44u8, 120u8, 94u8, 114u8, 106u8,
|
|
169u8, 4u8, 217u8, 220u8, 234u8, 57u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 128usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
owner: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
salt: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for LoadedBalance {
|
|
const NAME: &'static str = "LoadedBalance";
|
|
fn match_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 OwnershipHandoverCanceled {
|
|
pub pending_owner: Vec<u8>,
|
|
}
|
|
impl OwnershipHandoverCanceled {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
250u8, 123u8, 142u8, 171u8, 125u8, 166u8, 127u8, 65u8, 44u8, 201u8, 87u8, 94u8, 212u8,
|
|
52u8, 100u8, 70u8, 143u8, 155u8, 251u8, 174u8, 137u8, 209u8, 103u8, 89u8, 23u8, 52u8,
|
|
108u8, 166u8, 216u8, 254u8, 60u8, 146u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 2usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 0usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Ok(Self {
|
|
pending_owner: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'pending_owner' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for OwnershipHandoverCanceled {
|
|
const NAME: &'static str = "OwnershipHandoverCanceled";
|
|
fn match_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 OwnershipHandoverRequested {
|
|
pub pending_owner: Vec<u8>,
|
|
}
|
|
impl OwnershipHandoverRequested {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
219u8, 243u8, 106u8, 16u8, 125u8, 161u8, 158u8, 73u8, 82u8, 122u8, 113u8, 118u8, 161u8,
|
|
186u8, 191u8, 150u8, 59u8, 75u8, 15u8, 248u8, 205u8, 227u8, 94u8, 227u8, 93u8, 108u8,
|
|
216u8, 241u8, 249u8, 172u8, 126u8, 29u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 2usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 0usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Ok(Self {
|
|
pending_owner: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'pending_owner' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for OwnershipHandoverRequested {
|
|
const NAME: &'static str = "OwnershipHandoverRequested";
|
|
fn match_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 OwnershipTransferred {
|
|
pub old_owner: Vec<u8>,
|
|
pub new_owner: Vec<u8>,
|
|
}
|
|
impl OwnershipTransferred {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
139u8, 224u8, 7u8, 156u8, 83u8, 22u8, 89u8, 20u8, 19u8, 68u8, 205u8, 31u8, 208u8,
|
|
164u8, 242u8, 132u8, 25u8, 73u8, 127u8, 151u8, 34u8, 163u8, 218u8, 175u8, 227u8, 180u8,
|
|
24u8, 111u8, 107u8, 100u8, 87u8, 224u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 3usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 0usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Ok(Self {
|
|
old_owner: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'old_owner' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
new_owner: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[2usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'new_owner' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for OwnershipTransferred {
|
|
const NAME: &'static str = "OwnershipTransferred";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PoolInitialized {
|
|
pub pool_id: [u8; 32usize],
|
|
pub pool_key: (Vec<u8>, Vec<u8>, [u8; 32usize]),
|
|
pub tick: substreams::scalar::BigInt,
|
|
pub sqrt_ratio: substreams::scalar::BigInt,
|
|
}
|
|
impl PoolInitialized {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
94u8, 70u8, 136u8, 179u8, 64u8, 105u8, 75u8, 124u8, 127u8, 211u8, 0u8, 71u8, 253u8,
|
|
8u8, 33u8, 23u8, 220u8, 70u8, 227u8, 42u8, 207u8, 191u8, 129u8, 164u8, 75u8, 177u8,
|
|
250u8, 192u8, 174u8, 101u8, 21u8, 77u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 192usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
]),
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Uint(96usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
pool_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[2usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
)
|
|
},
|
|
tick: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
sqrt_ratio: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for PoolInitialized {
|
|
const NAME: &'static str = "PoolInitialized";
|
|
fn match_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 PositionFeesCollected {
|
|
pub pool_id: [u8; 32usize],
|
|
pub position_key:
|
|
([u8; 32usize], Vec<u8>, (substreams::scalar::BigInt, substreams::scalar::BigInt)),
|
|
pub amount0: substreams::scalar::BigInt,
|
|
pub amount1: substreams::scalar::BigInt,
|
|
}
|
|
impl PositionFeesCollected {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
187u8, 57u8, 146u8, 216u8, 60u8, 114u8, 31u8, 18u8, 168u8, 243u8, 34u8, 66u8, 224u8,
|
|
210u8, 28u8, 54u8, 19u8, 148u8, 156u8, 106u8, 105u8, 210u8, 163u8, 93u8, 238u8, 205u8,
|
|
246u8, 148u8, 58u8, 97u8, 200u8, 178u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 224usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
]),
|
|
]),
|
|
ethabi::ParamType::Uint(128usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
position_key: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[0usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let tuple_elements = tuple_elements[2usize]
|
|
.clone()
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
)
|
|
},
|
|
amount0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for PositionFeesCollected {
|
|
const NAME: &'static str = "PositionFeesCollected";
|
|
fn match_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 PositionUpdated {
|
|
pub locker: Vec<u8>,
|
|
pub pool_id: [u8; 32usize],
|
|
pub params: (
|
|
[u8; 32usize],
|
|
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
|
substreams::scalar::BigInt,
|
|
),
|
|
pub delta0: substreams::scalar::BigInt,
|
|
pub delta1: substreams::scalar::BigInt,
|
|
}
|
|
impl PositionUpdated {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
162u8, 212u8, 0u8, 139u8, 228u8, 24u8, 124u8, 99u8, 104u8, 79u8, 50u8, 55u8, 136u8,
|
|
225u8, 49u8, 225u8, 55u8, 13u8, 188u8, 34u8, 5u8, 73u8, 155u8, 239u8, 226u8, 131u8,
|
|
64u8, 5u8, 160u8, 12u8, 121u8, 44u8,
|
|
];
|
|
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::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Tuple(vec![
|
|
ethabi::ParamType::Int(32usize),
|
|
ethabi::ParamType::Int(32usize),
|
|
]),
|
|
ethabi::ParamType::Int(128usize),
|
|
]),
|
|
ethabi::ParamType::Int(128usize),
|
|
ethabi::ParamType::Int(128usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
locker: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
pool_id: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
params: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = tuple_elements[0usize]
|
|
.clone()
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
{
|
|
let tuple_elements = tuple_elements[1usize]
|
|
.clone()
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
)
|
|
},
|
|
delta0: {
|
|
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)
|
|
},
|
|
delta1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_int()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_signed_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for PositionUpdated {
|
|
const NAME: &'static str = "PositionUpdated";
|
|
fn match_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 ProtocolFeesWithdrawn {
|
|
pub recipient: Vec<u8>,
|
|
pub token: Vec<u8>,
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl ProtocolFeesWithdrawn {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
143u8, 194u8, 65u8, 48u8, 143u8, 252u8, 23u8, 129u8, 126u8, 106u8, 140u8, 106u8, 82u8,
|
|
168u8, 247u8, 205u8, 73u8, 49u8, 223u8, 202u8, 12u8, 83u8, 159u8, 211u8, 90u8, 99u8,
|
|
3u8, 17u8, 199u8, 228u8, 197u8, 123u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 96usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
recipient: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for ProtocolFeesWithdrawn {
|
|
const NAME: &'static str = "ProtocolFeesWithdrawn";
|
|
fn match_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 SavedBalance {
|
|
pub owner: Vec<u8>,
|
|
pub token: Vec<u8>,
|
|
pub salt: [u8; 32usize],
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl SavedBalance {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
174u8, 210u8, 149u8, 31u8, 166u8, 91u8, 95u8, 239u8, 236u8, 236u8, 23u8, 0u8, 103u8,
|
|
193u8, 210u8, 138u8, 178u8, 101u8, 226u8, 13u8, 26u8, 232u8, 189u8, 96u8, 134u8, 5u8,
|
|
95u8, 80u8, 182u8, 20u8, 99u8, 88u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 128usize {
|
|
return false;
|
|
}
|
|
return log
|
|
.topics
|
|
.get(0)
|
|
.expect("bounds already checked")
|
|
.as_ref() ==
|
|
Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Uint(128usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
owner: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
salt: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
amount: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for SavedBalance {
|
|
const NAME: &'static str = "SavedBalance";
|
|
fn match_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)
|
|
}
|
|
}
|
|
}
|