fix(balancer): miscellaneous improvements before resync (#104)
* fix(balancer): ignore self balance change Euler pool emit a balance change for the pool itself. We don't want to have it because it's an unknown token from Tycho's perspective. example: https://etherscan.io/tx/0x4a9ea683052afefdae3d189862868c3a7dc8f431d1d9828b6bfd9451a8816426#eventlog#338 * refactor(balancer): rename balancer module to balancer-v2 * ci: make clippy happy --------- Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
1446
substreams/ethereum-balancer-v2/src/abi/erc_linear_pool_factory.rs
Normal file
1446
substreams/ethereum-balancer-v2/src/abi/erc_linear_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
1512
substreams/ethereum-balancer-v2/src/abi/euler_linear_pool_factory.rs
Normal file
1512
substreams/ethereum-balancer-v2/src/abi/euler_linear_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1568
substreams/ethereum-balancer-v2/src/abi/managed_pool_factory.rs
Normal file
1568
substreams/ethereum-balancer-v2/src/abi/managed_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
14
substreams/ethereum-balancer-v2/src/abi/mod.rs
Normal file
14
substreams/ethereum-balancer-v2/src/abi/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
#![allow(clippy::all)]
|
||||
pub mod yearn_linear_pool_factory;
|
||||
pub mod composable_stable_pool_factory;
|
||||
pub mod vault;
|
||||
pub mod weighted_pool_factory_v4;
|
||||
pub mod weighted_pool_tokens_factory;
|
||||
pub mod silo_linear_pool_factory;
|
||||
pub mod weighted_pool_factory_v3;
|
||||
pub mod weighted_pool_factory_v2;
|
||||
pub mod euler_linear_pool_factory;
|
||||
pub mod weighted_pool_factory_v1;
|
||||
pub mod managed_pool_factory;
|
||||
pub mod erc_linear_pool_factory;
|
||||
pub mod gearbox_linear_pool_factory;
|
||||
1446
substreams/ethereum-balancer-v2/src/abi/silo_linear_pool_factory.rs
Normal file
1446
substreams/ethereum-balancer-v2/src/abi/silo_linear_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
4588
substreams/ethereum-balancer-v2/src/abi/vault.rs
Normal file
4588
substreams/ethereum-balancer-v2/src/abi/vault.rs
Normal file
File diff suppressed because it is too large
Load Diff
1316
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory.rs
Normal file
1316
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,633 @@
|
||||
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
|
||||
/// Contract's functions.
|
||||
#[allow(dead_code, unused_imports, unused_variables)]
|
||||
pub mod functions {
|
||||
use super::INTERNAL_ERR;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Create {
|
||||
pub name: String,
|
||||
pub symbol: String,
|
||||
pub tokens: Vec<Vec<u8>>,
|
||||
pub weights: Vec<substreams::scalar::BigInt>,
|
||||
pub swap_fee_percentage: substreams::scalar::BigInt,
|
||||
pub owner: Vec<u8>,
|
||||
}
|
||||
impl Create {
|
||||
const METHOD_ID: [u8; 4] = [251u8, 206u8, 3u8, 147u8];
|
||||
pub fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
let maybe_data = call.input.get(4..);
|
||||
if maybe_data.is_none() {
|
||||
return Err("no data to decode".to_string());
|
||||
}
|
||||
let mut values = ethabi::decode(
|
||||
&[
|
||||
ethabi::ParamType::String,
|
||||
ethabi::ParamType::String,
|
||||
ethabi::ParamType::Array(
|
||||
Box::new(ethabi::ParamType::Address),
|
||||
),
|
||||
ethabi::ParamType::Array(
|
||||
Box::new(ethabi::ParamType::Uint(256usize)),
|
||||
),
|
||||
ethabi::ParamType::Uint(256usize),
|
||||
ethabi::ParamType::Address,
|
||||
],
|
||||
maybe_data.unwrap(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok(Self {
|
||||
name: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_string()
|
||||
.expect(INTERNAL_ERR),
|
||||
symbol: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_string()
|
||||
.expect(INTERNAL_ERR),
|
||||
tokens: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_array()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_iter()
|
||||
.map(|inner| {
|
||||
inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec()
|
||||
})
|
||||
.collect(),
|
||||
weights: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_array()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_iter()
|
||||
.map(|inner| {
|
||||
let mut v = [0 as u8; 32];
|
||||
inner
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
})
|
||||
.collect(),
|
||||
swap_fee_percentage: {
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
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::String(self.name.clone()),
|
||||
ethabi::Token::String(self.symbol.clone()),
|
||||
{
|
||||
let v = self
|
||||
.tokens
|
||||
.iter()
|
||||
.map(|inner| ethabi::Token::Address(
|
||||
ethabi::Address::from_slice(&inner),
|
||||
))
|
||||
.collect();
|
||||
ethabi::Token::Array(v)
|
||||
},
|
||||
{
|
||||
let v = self
|
||||
.weights
|
||||
.iter()
|
||||
.map(|inner| ethabi::Token::Uint(
|
||||
ethabi::Uint::from_big_endian(
|
||||
match inner.clone().to_bytes_be() {
|
||||
(num_bigint::Sign::Plus, bytes) => bytes,
|
||||
(num_bigint::Sign::NoSign, bytes) => bytes,
|
||||
(num_bigint::Sign::Minus, _) => {
|
||||
panic!("negative numbers are not supported")
|
||||
}
|
||||
}
|
||||
.as_slice(),
|
||||
),
|
||||
))
|
||||
.collect();
|
||||
ethabi::Token::Array(v)
|
||||
},
|
||||
ethabi::Token::Uint(
|
||||
ethabi::Uint::from_big_endian(
|
||||
match self.swap_fee_percentage.clone().to_bytes_be() {
|
||||
(num_bigint::Sign::Plus, bytes) => bytes,
|
||||
(num_bigint::Sign::NoSign, bytes) => bytes,
|
||||
(num_bigint::Sign::Minus, _) => {
|
||||
panic!("negative numbers are not supported")
|
||||
}
|
||||
}
|
||||
.as_slice(),
|
||||
),
|
||||
),
|
||||
ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)),
|
||||
],
|
||||
);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<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 Create {
|
||||
const NAME: &'static str = "create";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Create {
|
||||
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GetPauseConfiguration {}
|
||||
impl GetPauseConfiguration {
|
||||
const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8];
|
||||
pub fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
Ok(Self {})
|
||||
}
|
||||
pub fn encode(&self) -> Vec<u8> {
|
||||
let data = ethabi::encode(&[]);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<
|
||||
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
||||
String,
|
||||
> {
|
||||
Self::output(call.return_data.as_ref())
|
||||
}
|
||||
pub fn output(
|
||||
data: &[u8],
|
||||
) -> Result<
|
||||
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
||||
String,
|
||||
> {
|
||||
let mut values = ethabi::decode(
|
||||
&[
|
||||
ethabi::ParamType::Uint(256usize),
|
||||
ethabi::ParamType::Uint(256usize),
|
||||
],
|
||||
data.as_ref(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok((
|
||||
{
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
{
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
))
|
||||
}
|
||||
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
match call.input.get(0..4) {
|
||||
Some(signature) => Self::METHOD_ID == signature,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
pub fn call(
|
||||
&self,
|
||||
address: Vec<u8>,
|
||||
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> {
|
||||
use substreams_ethereum::pb::eth::rpc;
|
||||
let rpc_calls = rpc::RpcCalls {
|
||||
calls: vec![
|
||||
rpc::RpcCall { to_addr : address, data : self.encode(), }
|
||||
],
|
||||
};
|
||||
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
||||
let response = responses
|
||||
.get(0)
|
||||
.expect("one response should have existed");
|
||||
if response.failed {
|
||||
return None;
|
||||
}
|
||||
match Self::output(response.raw.as_ref()) {
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
use substreams_ethereum::Function;
|
||||
substreams::log::info!(
|
||||
"Call output for function `{}` failed to decode with error: {}",
|
||||
Self::NAME, err
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Function for GetPauseConfiguration {
|
||||
const NAME: &'static str = "getPauseConfiguration";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<
|
||||
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
||||
> for GetPauseConfiguration {
|
||||
fn output(
|
||||
data: &[u8],
|
||||
) -> Result<
|
||||
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
||||
String,
|
||||
> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GetVault {}
|
||||
impl GetVault {
|
||||
const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8];
|
||||
pub fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<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 GetVault {
|
||||
const NAME: &'static str = "getVault";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetVault {
|
||||
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct IsPoolFromFactory {
|
||||
pub pool: Vec<u8>,
|
||||
}
|
||||
impl IsPoolFromFactory {
|
||||
const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8];
|
||||
pub fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
let maybe_data = call.input.get(4..);
|
||||
if maybe_data.is_none() {
|
||||
return Err("no data to decode".to_string());
|
||||
}
|
||||
let mut values = ethabi::decode(
|
||||
&[ethabi::ParamType::Address],
|
||||
maybe_data.unwrap(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok(Self {
|
||||
pool: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
})
|
||||
}
|
||||
pub fn encode(&self) -> Vec<u8> {
|
||||
let data = ethabi::encode(
|
||||
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))],
|
||||
);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<bool, String> {
|
||||
Self::output(call.return_data.as_ref())
|
||||
}
|
||||
pub fn output(data: &[u8]) -> Result<bool, String> {
|
||||
let mut values = ethabi::decode(
|
||||
&[ethabi::ParamType::Bool],
|
||||
data.as_ref(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
||||
Ok(
|
||||
values
|
||||
.pop()
|
||||
.expect("one output data should have existed")
|
||||
.into_bool()
|
||||
.expect(INTERNAL_ERR),
|
||||
)
|
||||
}
|
||||
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
match call.input.get(0..4) {
|
||||
Some(signature) => Self::METHOD_ID == signature,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
pub fn call(&self, address: Vec<u8>) -> Option<bool> {
|
||||
use substreams_ethereum::pb::eth::rpc;
|
||||
let rpc_calls = rpc::RpcCalls {
|
||||
calls: vec![
|
||||
rpc::RpcCall { to_addr : address, data : self.encode(), }
|
||||
],
|
||||
};
|
||||
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
||||
let response = responses
|
||||
.get(0)
|
||||
.expect("one response should have existed");
|
||||
if response.failed {
|
||||
return None;
|
||||
}
|
||||
match Self::output(response.raw.as_ref()) {
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
use substreams_ethereum::Function;
|
||||
substreams::log::info!(
|
||||
"Call output for function `{}` failed to decode with error: {}",
|
||||
Self::NAME, err
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Function for IsPoolFromFactory {
|
||||
const NAME: &'static str = "isPoolFromFactory";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<bool> for IsPoolFromFactory {
|
||||
fn output(data: &[u8]) -> Result<bool, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Contract's events.
|
||||
#[allow(dead_code, unused_imports, unused_variables)]
|
||||
pub mod events {
|
||||
use super::INTERNAL_ERR;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PoolCreated {
|
||||
pub pool: Vec<u8>,
|
||||
}
|
||||
impl PoolCreated {
|
||||
const TOPIC_ID: [u8; 32] = [
|
||||
131u8,
|
||||
164u8,
|
||||
143u8,
|
||||
188u8,
|
||||
252u8,
|
||||
153u8,
|
||||
19u8,
|
||||
53u8,
|
||||
49u8,
|
||||
78u8,
|
||||
116u8,
|
||||
208u8,
|
||||
73u8,
|
||||
106u8,
|
||||
171u8,
|
||||
106u8,
|
||||
25u8,
|
||||
135u8,
|
||||
233u8,
|
||||
146u8,
|
||||
221u8,
|
||||
200u8,
|
||||
93u8,
|
||||
221u8,
|
||||
188u8,
|
||||
196u8,
|
||||
214u8,
|
||||
221u8,
|
||||
110u8,
|
||||
242u8,
|
||||
233u8,
|
||||
252u8,
|
||||
];
|
||||
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
||||
if log.topics.len() != 2usize {
|
||||
return false;
|
||||
}
|
||||
if log.data.len() != 0usize {
|
||||
return false;
|
||||
}
|
||||
return log.topics.get(0).expect("bounds already checked").as_ref()
|
||||
== Self::TOPIC_ID;
|
||||
}
|
||||
pub fn decode(
|
||||
log: &substreams_ethereum::pb::eth::v2::Log,
|
||||
) -> Result<Self, String> {
|
||||
Ok(Self {
|
||||
pool: ethabi::decode(
|
||||
&[ethabi::ParamType::Address],
|
||||
log.topics[1usize].as_ref(),
|
||||
)
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"unable to decode param 'pool' from topic of type 'address': {:?}",
|
||||
e
|
||||
)
|
||||
})?
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
})
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Event for PoolCreated {
|
||||
const NAME: &'static str = "PoolCreated";
|
||||
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
||||
Self::match_log(log)
|
||||
}
|
||||
fn decode(
|
||||
log: &substreams_ethereum::pb::eth::v2::Log,
|
||||
) -> Result<Self, String> {
|
||||
Self::decode(log)
|
||||
}
|
||||
}
|
||||
}
|
||||
1324
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v2.rs
Normal file
1324
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v2.rs
Normal file
File diff suppressed because it is too large
Load Diff
1498
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v3.rs
Normal file
1498
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v3.rs
Normal file
File diff suppressed because it is too large
Load Diff
1511
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v4.rs
Normal file
1511
substreams/ethereum-balancer-v2/src/abi/weighted_pool_factory_v4.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,558 @@
|
||||
|
||||
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
|
||||
/// Contract's functions.
|
||||
#[allow(dead_code, unused_imports, unused_variables)]
|
||||
pub mod functions {
|
||||
use super::INTERNAL_ERR;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Create {
|
||||
pub name: String,
|
||||
pub symbol: String,
|
||||
pub tokens: Vec<Vec<u8>>,
|
||||
pub weights: Vec<substreams::scalar::BigInt>,
|
||||
pub swap_fee_percentage: substreams::scalar::BigInt,
|
||||
pub oracle_enabled: bool,
|
||||
pub owner: Vec<u8>,
|
||||
}
|
||||
impl Create {
|
||||
const METHOD_ID: [u8; 4] = [21u8, 150u8, 1u8, 155u8];
|
||||
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
let maybe_data = call.input.get(4..);
|
||||
if maybe_data.is_none() {
|
||||
return Err("no data to decode".to_string());
|
||||
}
|
||||
let mut values = ethabi::decode(
|
||||
&[
|
||||
ethabi::ParamType::String,
|
||||
ethabi::ParamType::String,
|
||||
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)),
|
||||
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))),
|
||||
ethabi::ParamType::Uint(256usize),
|
||||
ethabi::ParamType::Bool,
|
||||
ethabi::ParamType::Address,
|
||||
],
|
||||
maybe_data.unwrap(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok(Self {
|
||||
name: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_string()
|
||||
.expect(INTERNAL_ERR),
|
||||
symbol: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_string()
|
||||
.expect(INTERNAL_ERR),
|
||||
tokens: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_array()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_iter()
|
||||
.map(|inner| {
|
||||
inner
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec()
|
||||
})
|
||||
.collect(),
|
||||
weights: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_array()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_iter()
|
||||
.map(|inner| {
|
||||
let mut v = [0 as u8; 32];
|
||||
inner
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
})
|
||||
.collect(),
|
||||
swap_fee_percentage: {
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
oracle_enabled: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_bool()
|
||||
.expect(INTERNAL_ERR),
|
||||
owner: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
})
|
||||
}
|
||||
pub fn encode(&self) -> Vec<u8> {
|
||||
let data = ethabi::encode(&[
|
||||
ethabi::Token::String(self.name.clone()),
|
||||
ethabi::Token::String(self.symbol.clone()),
|
||||
{
|
||||
let v = self
|
||||
.tokens
|
||||
.iter()
|
||||
.map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner)))
|
||||
.collect();
|
||||
ethabi::Token::Array(v)
|
||||
},
|
||||
{
|
||||
let v = self
|
||||
.weights
|
||||
.iter()
|
||||
.map(|inner| {
|
||||
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
||||
match inner.clone().to_bytes_be() {
|
||||
(num_bigint::Sign::Plus, bytes) => bytes,
|
||||
(num_bigint::Sign::NoSign, bytes) => bytes,
|
||||
(num_bigint::Sign::Minus, _) => {
|
||||
panic!("negative numbers are not supported")
|
||||
}
|
||||
}
|
||||
.as_slice(),
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
ethabi::Token::Array(v)
|
||||
},
|
||||
ethabi::Token::Uint(ethabi::Uint::from_big_endian(
|
||||
match self
|
||||
.swap_fee_percentage
|
||||
.clone()
|
||||
.to_bytes_be()
|
||||
{
|
||||
(num_bigint::Sign::Plus, bytes) => bytes,
|
||||
(num_bigint::Sign::NoSign, bytes) => bytes,
|
||||
(num_bigint::Sign::Minus, _) => {
|
||||
panic!("negative numbers are not supported")
|
||||
}
|
||||
}
|
||||
.as_slice(),
|
||||
)),
|
||||
ethabi::Token::Bool(self.oracle_enabled.clone()),
|
||||
ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)),
|
||||
]);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<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 Create {
|
||||
const NAME: &'static str = "create";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Create {
|
||||
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GetPauseConfiguration {}
|
||||
impl GetPauseConfiguration {
|
||||
const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8];
|
||||
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
Ok(Self {})
|
||||
}
|
||||
pub fn encode(&self) -> Vec<u8> {
|
||||
let data = ethabi::encode(&[]);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(
|
||||
call: &substreams_ethereum::pb::eth::v2::Call,
|
||||
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
||||
Self::output(call.return_data.as_ref())
|
||||
}
|
||||
pub fn output(
|
||||
data: &[u8],
|
||||
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
||||
let mut values = ethabi::decode(
|
||||
&[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize)],
|
||||
data.as_ref(),
|
||||
)
|
||||
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok((
|
||||
{
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
{
|
||||
let mut v = [0 as u8; 32];
|
||||
values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_uint()
|
||||
.expect(INTERNAL_ERR)
|
||||
.to_big_endian(v.as_mut_slice());
|
||||
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
||||
},
|
||||
))
|
||||
}
|
||||
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
match call.input.get(0..4) {
|
||||
Some(signature) => Self::METHOD_ID == signature,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
pub fn call(
|
||||
&self,
|
||||
address: Vec<u8>,
|
||||
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> {
|
||||
use substreams_ethereum::pb::eth::rpc;
|
||||
let rpc_calls = rpc::RpcCalls {
|
||||
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
||||
};
|
||||
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
||||
let response = responses
|
||||
.get(0)
|
||||
.expect("one response should have existed");
|
||||
if response.failed {
|
||||
return None;
|
||||
}
|
||||
match Self::output(response.raw.as_ref()) {
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
use substreams_ethereum::Function;
|
||||
substreams::log::info!(
|
||||
"Call output for function `{}` failed to decode with error: {}",
|
||||
Self::NAME,
|
||||
err
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Function for GetPauseConfiguration {
|
||||
const NAME: &'static str = "getPauseConfiguration";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl
|
||||
substreams_ethereum::rpc::RPCDecodable<(
|
||||
substreams::scalar::BigInt,
|
||||
substreams::scalar::BigInt,
|
||||
)> for GetPauseConfiguration
|
||||
{
|
||||
fn output(
|
||||
data: &[u8],
|
||||
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GetVault {}
|
||||
impl GetVault {
|
||||
const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8];
|
||||
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<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 GetVault {
|
||||
const NAME: &'static str = "getVault";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for GetVault {
|
||||
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct IsPoolFromFactory {
|
||||
pub pool: Vec<u8>,
|
||||
}
|
||||
impl IsPoolFromFactory {
|
||||
const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8];
|
||||
pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
let maybe_data = call.input.get(4..);
|
||||
if maybe_data.is_none() {
|
||||
return Err("no data to decode".to_string());
|
||||
}
|
||||
let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap())
|
||||
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
||||
values.reverse();
|
||||
Ok(Self {
|
||||
pool: values
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
})
|
||||
}
|
||||
pub fn encode(&self) -> Vec<u8> {
|
||||
let data =
|
||||
ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]);
|
||||
let mut encoded = Vec::with_capacity(4 + data.len());
|
||||
encoded.extend(Self::METHOD_ID);
|
||||
encoded.extend(data);
|
||||
encoded
|
||||
}
|
||||
pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<bool, String> {
|
||||
Self::output(call.return_data.as_ref())
|
||||
}
|
||||
pub fn output(data: &[u8]) -> Result<bool, String> {
|
||||
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
||||
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
||||
Ok(values
|
||||
.pop()
|
||||
.expect("one output data should have existed")
|
||||
.into_bool()
|
||||
.expect(INTERNAL_ERR))
|
||||
}
|
||||
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
match call.input.get(0..4) {
|
||||
Some(signature) => Self::METHOD_ID == signature,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
pub fn call(&self, address: Vec<u8>) -> Option<bool> {
|
||||
use substreams_ethereum::pb::eth::rpc;
|
||||
let rpc_calls = rpc::RpcCalls {
|
||||
calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }],
|
||||
};
|
||||
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
||||
let response = responses
|
||||
.get(0)
|
||||
.expect("one response should have existed");
|
||||
if response.failed {
|
||||
return None;
|
||||
}
|
||||
match Self::output(response.raw.as_ref()) {
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
use substreams_ethereum::Function;
|
||||
substreams::log::info!(
|
||||
"Call output for function `{}` failed to decode with error: {}",
|
||||
Self::NAME,
|
||||
err
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Function for IsPoolFromFactory {
|
||||
const NAME: &'static str = "isPoolFromFactory";
|
||||
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
||||
Self::match_call(call)
|
||||
}
|
||||
fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result<Self, String> {
|
||||
Self::decode(call)
|
||||
}
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.encode()
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::rpc::RPCDecodable<bool> for IsPoolFromFactory {
|
||||
fn output(data: &[u8]) -> Result<bool, String> {
|
||||
Self::output(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Contract's events.
|
||||
#[allow(dead_code, unused_imports, unused_variables)]
|
||||
pub mod events {
|
||||
use super::INTERNAL_ERR;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PoolCreated {
|
||||
pub pool: Vec<u8>,
|
||||
}
|
||||
impl PoolCreated {
|
||||
const TOPIC_ID: [u8; 32] = [
|
||||
131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8,
|
||||
106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8,
|
||||
196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8,
|
||||
];
|
||||
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
||||
if log.topics.len() != 2usize {
|
||||
return false;
|
||||
}
|
||||
if log.data.len() != 0usize {
|
||||
return false;
|
||||
}
|
||||
return log
|
||||
.topics
|
||||
.get(0)
|
||||
.expect("bounds already checked")
|
||||
.as_ref()
|
||||
== Self::TOPIC_ID;
|
||||
}
|
||||
pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
||||
Ok(Self {
|
||||
pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref())
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"unable to decode param 'pool' from topic of type 'address': {:?}",
|
||||
e
|
||||
)
|
||||
})?
|
||||
.pop()
|
||||
.expect(INTERNAL_ERR)
|
||||
.into_address()
|
||||
.expect(INTERNAL_ERR)
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
})
|
||||
}
|
||||
}
|
||||
impl substreams_ethereum::Event for PoolCreated {
|
||||
const NAME: &'static str = "PoolCreated";
|
||||
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
||||
Self::match_log(log)
|
||||
}
|
||||
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
||||
Self::decode(log)
|
||||
}
|
||||
}
|
||||
}
|
||||
1446
substreams/ethereum-balancer-v2/src/abi/yearn_linear_pool_factory.rs
Normal file
1446
substreams/ethereum-balancer-v2/src/abi/yearn_linear_pool_factory.rs
Normal file
File diff suppressed because it is too large
Load Diff
3
substreams/ethereum-balancer-v2/src/lib.rs
Normal file
3
substreams/ethereum-balancer-v2/src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
mod abi;
|
||||
mod modules;
|
||||
mod pool_factories;
|
||||
267
substreams/ethereum-balancer-v2/src/modules.rs
Normal file
267
substreams/ethereum-balancer-v2/src/modules.rs
Normal file
@@ -0,0 +1,267 @@
|
||||
use crate::{abi, pool_factories};
|
||||
use anyhow::Result;
|
||||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
use substreams::{
|
||||
hex,
|
||||
pb::substreams::StoreDeltas,
|
||||
store::{StoreAddBigInt, StoreGet, StoreGetString, StoreNew, StoreSet, StoreSetString},
|
||||
};
|
||||
use substreams_ethereum::{pb::eth, Event};
|
||||
use tycho_substreams::{
|
||||
balances::aggregate_balances_changes, contract::extract_contract_changes_builder, prelude::*,
|
||||
};
|
||||
|
||||
pub const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
||||
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_components(block: eth::v2::Block) -> Result<BlockTransactionProtocolComponents> {
|
||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
||||
// We store these as a hashmap by tx hash since we need to agg by tx hash later
|
||||
Ok(BlockTransactionProtocolComponents {
|
||||
tx_components: block
|
||||
.transactions()
|
||||
.filter_map(|tx| {
|
||||
let components = tx
|
||||
.logs_with_calls()
|
||||
.filter_map(|(log, call)| {
|
||||
pool_factories::address_map(
|
||||
call.call.address.as_slice(),
|
||||
log,
|
||||
call.call,
|
||||
tx,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !components.is_empty() {
|
||||
Some(TransactionProtocolComponents { tx: Some(tx.into()), components })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Simply stores the `ProtocolComponent`s with the pool address as the key and the pool id as value
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_components(map: BlockTransactionProtocolComponents, store: StoreSetString) {
|
||||
map.tx_components
|
||||
.into_iter()
|
||||
.for_each(|tx_pc| {
|
||||
tx_pc
|
||||
.components
|
||||
.into_iter()
|
||||
.for_each(|pc| store.set(0, format!("pool:{0}", &pc.id[..42]), &pc.id))
|
||||
});
|
||||
}
|
||||
|
||||
/// Since the `PoolBalanceChanged` and `Swap` events administer only deltas, we need to leverage a
|
||||
/// map and a store to be able to tally up final balances for tokens in a pool.
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_relative_balances(
|
||||
block: eth::v2::Block,
|
||||
store: StoreGetString,
|
||||
) -> Result<BlockBalanceDeltas, anyhow::Error> {
|
||||
let balance_deltas = block
|
||||
.logs()
|
||||
.filter(|log| log.address() == VAULT_ADDRESS)
|
||||
.flat_map(|vault_log| {
|
||||
let mut deltas = Vec::new();
|
||||
|
||||
if let Some(ev) =
|
||||
abi::vault::events::PoolBalanceChanged::match_and_decode(vault_log.log)
|
||||
{
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
|
||||
if store
|
||||
.get_last(format!("pool:{}", &component_id[..42]))
|
||||
.is_some()
|
||||
{
|
||||
for (token, delta) in ev
|
||||
.tokens
|
||||
.iter()
|
||||
.zip(ev.deltas.iter())
|
||||
.filter(|(token, _)| **token != hex::decode(&component_id[2..42]).unwrap())
|
||||
{
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: token.to_vec(),
|
||||
delta: delta.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if let Some(ev) = abi::vault::events::Swap::match_and_decode(vault_log.log) {
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
|
||||
if store
|
||||
.get_last(format!("pool:{}", &component_id[..42]))
|
||||
.is_some()
|
||||
{
|
||||
deltas.extend_from_slice(&[
|
||||
BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token_in.to_vec(),
|
||||
delta: ev.amount_in.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
},
|
||||
BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token_out.to_vec(),
|
||||
delta: ev.amount_out.neg().to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
},
|
||||
]);
|
||||
}
|
||||
} else if let Some(ev) =
|
||||
abi::vault::events::PoolBalanceManaged::match_and_decode(vault_log.log)
|
||||
{
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
deltas.extend_from_slice(&[BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token.to_vec(),
|
||||
delta: ev.cash_delta.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
}]);
|
||||
}
|
||||
|
||||
deltas
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok(BlockBalanceDeltas { balance_deltas })
|
||||
}
|
||||
|
||||
/// It's significant to include both the `pool_id` and the `token_id` for each balance delta as the
|
||||
/// store key to ensure that there's a unique balance being tallied for each.
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_balances(deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
|
||||
tycho_substreams::balances::store_balance_changes(deltas, store);
|
||||
}
|
||||
|
||||
/// This is the main map that handles most of the indexing of this substream.
|
||||
/// Every contract change is grouped by transaction index via the `transaction_changes`
|
||||
/// map. Each block of code will extend the `TransactionChanges` struct with the
|
||||
/// cooresponding changes (balance, component, contract), inserting a new one if it doesn't exist.
|
||||
/// At the very end, the map can easily be sorted by index to ensure the final
|
||||
/// `BlockChanges` is ordered by transactions properly.
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_protocol_changes(
|
||||
block: eth::v2::Block,
|
||||
grouped_components: BlockTransactionProtocolComponents,
|
||||
deltas: BlockBalanceDeltas,
|
||||
components_store: StoreGetString,
|
||||
balance_store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store.
|
||||
) -> Result<BlockChanges> {
|
||||
// We merge contract changes by transaction (identified by transaction index) making it easy to
|
||||
// sort them at the very end.
|
||||
let mut transaction_changes: HashMap<_, TransactionChangesBuilder> = HashMap::new();
|
||||
|
||||
// `ProtocolComponents` are gathered from `map_pools_created` which just need a bit of work to
|
||||
// convert into `TransactionChanges`
|
||||
let default_attributes = vec![
|
||||
Attribute {
|
||||
name: "balance_owner".to_string(),
|
||||
value: VAULT_ADDRESS.to_vec(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "update_marker".to_string(),
|
||||
value: vec![1u8],
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
];
|
||||
grouped_components
|
||||
.tx_components
|
||||
.iter()
|
||||
.for_each(|tx_component| {
|
||||
// initialise builder if not yet present for this tx
|
||||
let tx = tx_component.tx.as_ref().unwrap();
|
||||
let builder = transaction_changes
|
||||
.entry(tx.index)
|
||||
.or_insert_with(|| TransactionChangesBuilder::new(tx));
|
||||
|
||||
// iterate over individual components created within this tx
|
||||
tx_component
|
||||
.components
|
||||
.iter()
|
||||
.for_each(|component| {
|
||||
builder.add_protocol_component(component);
|
||||
let entity_change = EntityChanges {
|
||||
component_id: component.id.clone(),
|
||||
attributes: default_attributes.clone(),
|
||||
};
|
||||
builder.add_entity_change(&entity_change)
|
||||
});
|
||||
});
|
||||
|
||||
// Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` creating
|
||||
// `BlockBalanceDeltas`. We essentially just process the changes that occurred to the `store`
|
||||
// this block. Then, these balance changes are merged onto the existing map of tx contract
|
||||
// changes, inserting a new one if it doesn't exist.
|
||||
aggregate_balances_changes(balance_store, deltas)
|
||||
.into_iter()
|
||||
.for_each(|(_, (tx, balances))| {
|
||||
let builder = transaction_changes
|
||||
.entry(tx.index)
|
||||
.or_insert_with(|| TransactionChangesBuilder::new(&tx));
|
||||
balances
|
||||
.values()
|
||||
.for_each(|token_bc_map| {
|
||||
token_bc_map
|
||||
.values()
|
||||
.for_each(|bc| builder.add_balance_change(bc))
|
||||
});
|
||||
});
|
||||
|
||||
// Extract and insert any storage changes that happened for any of the components.
|
||||
extract_contract_changes_builder(
|
||||
&block,
|
||||
|addr| {
|
||||
components_store
|
||||
.get_last(format!("pool:0x{0}", hex::encode(addr)))
|
||||
.is_some() ||
|
||||
addr.eq(VAULT_ADDRESS)
|
||||
},
|
||||
&mut transaction_changes,
|
||||
);
|
||||
|
||||
transaction_changes
|
||||
.iter_mut()
|
||||
.for_each(|(_, change)| {
|
||||
// this indirection is necessary due to borrowing rules.
|
||||
let addresses = change
|
||||
.changed_contracts()
|
||||
.map(|e| e.to_vec())
|
||||
.collect::<Vec<_>>();
|
||||
addresses
|
||||
.into_iter()
|
||||
.for_each(|address| {
|
||||
if address != VAULT_ADDRESS {
|
||||
// We reconstruct the component_id from the address here
|
||||
let id = components_store
|
||||
.get_last(format!("pool:0x{}", hex::encode(address)))
|
||||
.unwrap(); // Shouldn't happen because we filter by known components in
|
||||
// `extract_contract_changes_builder`
|
||||
change.mark_component_as_updated(&id);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Process all `transaction_changes` for final output in the `BlockChanges`,
|
||||
// sorted by transaction index (the key).
|
||||
Ok(BlockChanges {
|
||||
block: Some((&block).into()),
|
||||
changes: transaction_changes
|
||||
.drain()
|
||||
.sorted_unstable_by_key(|(index, _)| *index)
|
||||
.filter_map(|(_, builder)| builder.build())
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
437
substreams/ethereum-balancer-v2/src/pool_factories.rs
Normal file
437
substreams/ethereum-balancer-v2/src/pool_factories.rs
Normal file
@@ -0,0 +1,437 @@
|
||||
use crate::{abi, modules::VAULT_ADDRESS};
|
||||
use substreams::hex;
|
||||
use substreams_ethereum::{
|
||||
pb::eth::v2::{Call, Log, TransactionTrace},
|
||||
Event, Function,
|
||||
};
|
||||
use tycho_substreams::{
|
||||
attributes::{json_serialize_address_list, json_serialize_bigint_list},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
/// Helper function to get pool_registered event
|
||||
fn get_pool_registered(
|
||||
tx: &TransactionTrace,
|
||||
pool_address: &Vec<u8>,
|
||||
) -> abi::vault::events::PoolRegistered {
|
||||
tx.logs_with_calls()
|
||||
.filter(|(log, _)| log.address == VAULT_ADDRESS)
|
||||
.filter_map(|(log, _)| abi::vault::events::PoolRegistered::match_and_decode(log))
|
||||
.find(|pool| pool.pool_address == *pool_address)
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn get_token_registered(
|
||||
tx: &TransactionTrace,
|
||||
pool_id: &[u8],
|
||||
) -> abi::vault::events::TokensRegistered {
|
||||
tx.logs_with_calls()
|
||||
.filter(|(log, _)| log.address == VAULT_ADDRESS)
|
||||
.filter_map(|(log, _)| abi::vault::events::TokensRegistered::match_and_decode(log))
|
||||
.find(|ev| ev.pool_id == pool_id)
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
||||
// This is the main function that handles the creation of `ProtocolComponent`s with `Attribute`s
|
||||
// based on the specific factory address. There's 3 factory groups that are represented here:
|
||||
// - Weighted Pool Factories
|
||||
// - Linear Pool Factories
|
||||
// - Stable Pool Factories
|
||||
// (Balancer does have a bit more (esp. in the deprecated section) that could be implemented as
|
||||
// desired.)
|
||||
// We use the specific ABIs to decode both the log event and corresponding call to gather
|
||||
// `PoolCreated` event information alongside the `Create` call data that provide us details to
|
||||
// fulfill both the required details + any extra `Attributes`
|
||||
// Ref: https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html
|
||||
pub fn address_map(
|
||||
pool_factory_address: &[u8],
|
||||
log: &Log,
|
||||
call: &Call,
|
||||
tx: &TransactionTrace,
|
||||
) -> Option<ProtocolComponent> {
|
||||
match *pool_factory_address {
|
||||
hex!("8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9") => {
|
||||
let create_call =
|
||||
abi::weighted_pool_factory_v1::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::weighted_pool_factory_v1::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&create_call.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "WeightedPoolFactoryV1".as_bytes()),
|
||||
("normalized_weights", &json_serialize_bigint_list(&create_call.weights)),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("cC508a455F5b0073973107Db6a878DdBDab957bC") => {
|
||||
let create_call =
|
||||
abi::weighted_pool_factory_v2::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::weighted_pool_factory_v2::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&create_call.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "WeightedPoolFactoryV2".as_bytes()),
|
||||
(
|
||||
"normalized_weights",
|
||||
&json_serialize_bigint_list(&create_call.normalized_weights),
|
||||
),
|
||||
("rate_providers", &json_serialize_address_list(&create_call.rate_providers)),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("5Dd94Da3644DDD055fcf6B3E1aa310Bb7801EB8b") => {
|
||||
let create_call =
|
||||
abi::weighted_pool_factory_v3::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::weighted_pool_factory_v3::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&create_call.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "WeightedPoolFactoryV3".as_bytes()),
|
||||
(
|
||||
"normalized_weights",
|
||||
&json_serialize_bigint_list(&create_call.normalized_weights),
|
||||
),
|
||||
("rate_providers", &json_serialize_address_list(&create_call.rate_providers)),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("897888115Ada5773E02aA29F775430BFB5F34c51") => {
|
||||
let create_call =
|
||||
abi::weighted_pool_factory_v4::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::weighted_pool_factory_v4::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&create_call.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "WeightedPoolFactoryV4".as_bytes()),
|
||||
(
|
||||
"normalized_weights",
|
||||
&json_serialize_bigint_list(&create_call.normalized_weights),
|
||||
),
|
||||
("rate_providers", &json_serialize_address_list(&create_call.rate_providers)),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("DB8d758BCb971e482B2C45f7F8a7740283A1bd3A") => {
|
||||
let create_call =
|
||||
abi::composable_stable_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::composable_stable_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
let tokens_registered = get_token_registered(tx, &pool_registered.pool_id);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&tokens_registered.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "ComposableStablePoolFactory".as_bytes()),
|
||||
("bpt", &pool_created.pool),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("rate_providers", &json_serialize_address_list(&create_call.rate_providers)),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("813EE7a840CE909E7Fea2117A44a90b8063bd4fd") => {
|
||||
let create_call =
|
||||
abi::erc_linear_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::erc_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
let tokens_registered = get_token_registered(tx, &pool_registered.pool_id);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&tokens_registered.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "ERC4626LinearPoolFactory".as_bytes()),
|
||||
(
|
||||
"upper_target",
|
||||
&create_call
|
||||
.upper_target
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
("bpt", &pool_created.pool),
|
||||
("main_token", &create_call.main_token),
|
||||
("wrapped_token", &create_call.wrapped_token),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("5F43FBa61f63Fa6bFF101a0A0458cEA917f6B347") => {
|
||||
let create_call =
|
||||
abi::euler_linear_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::euler_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
let tokens_registered = get_token_registered(tx, &pool_registered.pool_id);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&tokens_registered.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "EulerLinearPoolFactory".as_bytes()),
|
||||
(
|
||||
"upper_target",
|
||||
&create_call
|
||||
.upper_target
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
("bpt", &pool_created.pool),
|
||||
("main_token", &create_call.main_token),
|
||||
("wrapped_token", &create_call.wrapped_token),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
// ❌ Reading the deployed factory for Gearbox showcases that it's currently disabled
|
||||
// hex!("39A79EB449Fc05C92c39aA6f0e9BfaC03BE8dE5B") => {
|
||||
// let create_call =
|
||||
// abi::gearbox_linear_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
// let pool_created =
|
||||
// abi::gearbox_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
|
||||
// Some(tycho::ProtocolComponent {
|
||||
// id: hex::encode(&pool_created.pool),
|
||||
// tokens: vec![create_call.main_token, create_call.wrapped_token],
|
||||
// contracts: vec![pool_addr.into(), pool_created.pool],
|
||||
// static_att: vec![
|
||||
// tycho::Attribute {
|
||||
// name: "pool_type".into(),
|
||||
// value: "GearboxLinearPoolFactory".into(),
|
||||
// change: tycho::ChangeType::Creation.into(),
|
||||
// },
|
||||
// tycho::Attribute {
|
||||
// name: "upper_target".into(),
|
||||
// value: create_call.upper_target.to_signed_bytes_be(),
|
||||
// change: tycho::ChangeType::Creation.into(),
|
||||
// },
|
||||
// ],
|
||||
// change: tycho::ChangeType::Creation.into(),
|
||||
// })
|
||||
// }
|
||||
// ❌ The `ManagedPoolFactory` is a bit ✨ unique ✨, so we'll leave it commented out for
|
||||
// now Take a look at it's `Create` call to see how the params are structured.
|
||||
// hex!("BF904F9F340745B4f0c4702c7B6Ab1e808eA6b93") => {
|
||||
// let create_call =
|
||||
// abi::managed_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
// let pool_created =
|
||||
// abi::managed_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
|
||||
// Some(tycho::ProtocolComponent {
|
||||
// id: hex::encode(&pool_created.pool),
|
||||
// tokens: create_call.tokens,
|
||||
// contracts: vec![pool_addr.into(), pool_created.pool],
|
||||
// static_att: vec![
|
||||
// tycho::Attribute {
|
||||
// name: "pool_type".into(),
|
||||
// value: "ManagedPoolFactory".into(),
|
||||
// change: tycho::ChangeType::Creation.into(),
|
||||
// },
|
||||
// ],
|
||||
// change: tycho::ChangeType::Creation.into(),
|
||||
// })
|
||||
// }
|
||||
hex!("4E11AEec21baF1660b1a46472963cB3DA7811C89") => {
|
||||
let create_call =
|
||||
abi::silo_linear_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::silo_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
let tokens_registered = get_token_registered(tx, &pool_registered.pool_id);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&tokens_registered.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "SiloLinearPoolFactory".as_bytes()),
|
||||
(
|
||||
"upper_target",
|
||||
&create_call
|
||||
.upper_target
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
("bpt", &pool_created.pool),
|
||||
("main_token", &create_call.main_token),
|
||||
("wrapped_token", &create_call.wrapped_token),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
hex!("5F5222Ffa40F2AEd6380D022184D6ea67C776eE0") => {
|
||||
let create_call =
|
||||
abi::yearn_linear_pool_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::yearn_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
let tokens_registered = get_token_registered(tx, &pool_registered.pool_id);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&tokens_registered.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "YearnLinearPoolFactory".as_bytes()),
|
||||
(
|
||||
"upper_target",
|
||||
&create_call
|
||||
.upper_target
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
("bpt", &pool_created.pool),
|
||||
("main_token", &create_call.main_token),
|
||||
("wrapped_token", &create_call.wrapped_token),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
// The `WeightedPool2TokenFactory` is a deprecated contract, but we've included
|
||||
// it to be able to track one of the highest TVL pools: 80BAL-20WETH.
|
||||
hex!("A5bf2ddF098bb0Ef6d120C98217dD6B141c74EE0") => {
|
||||
let create_call =
|
||||
abi::weighted_pool_tokens_factory::functions::Create::match_and_decode(call)?;
|
||||
let pool_created =
|
||||
abi::weighted_pool_tokens_factory::events::PoolCreated::match_and_decode(log)?;
|
||||
let pool_registered = get_pool_registered(tx, &pool_created.pool);
|
||||
|
||||
Some(
|
||||
ProtocolComponent::new(
|
||||
&format!("0x{}", hex::encode(pool_registered.pool_id)),
|
||||
&(tx.into()),
|
||||
)
|
||||
.with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()])
|
||||
.with_tokens(&create_call.tokens)
|
||||
.with_attributes(&[
|
||||
("pool_type", "WeightedPool2TokensFactory".as_bytes()),
|
||||
("weights", &json_serialize_bigint_list(&create_call.weights)),
|
||||
(
|
||||
"fee",
|
||||
&create_call
|
||||
.swap_fee_percentage
|
||||
.to_signed_bytes_be(),
|
||||
),
|
||||
("manual_updates", &[1u8]),
|
||||
])
|
||||
.as_swap_type("balancer_v2_pool", ImplementationType::Vm),
|
||||
)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user