fix(curve): index tricrypto2 dependencies

This commit is contained in:
Florian Pellissier
2024-08-05 13:58:12 +02:00
parent 9fa382ea60
commit 388902b2ed
7 changed files with 86 additions and 57 deletions

View File

@@ -17,3 +17,8 @@ pub const WETH_ADDRESS: [u8; 20] = hex!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc
pub const ETH_ADDRESS: [u8; 20] = hex!("EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE");
pub const OLD_SUSD: [u8; 20] = hex!("57Ab1E02fEE23774580C119740129eAC7081e9D3");
pub const NEW_SUSD: [u8; 20] = hex!("57ab1ec28d129707052df4df418d58a2d46d5f51");
pub const TRICRYPTO_2_LP: [u8; 20] = hex!("c4ad29ba4b3c580e6d59105fff484999997675ff");
pub const TRICRYPTO_2_MATH_CONTRACT: [u8; 20] = hex!("40745803c2faa8e8402e2ae935933d07ca8f355c");
pub const CONTRACTS_TO_INDEX: [[u8; 20]; 4] =
[CRYPTO_SWAP_NG_FACTORY, TRICRYPTO_FACTORY, TRICRYPTO_2_LP, TRICRYPTO_2_MATH_CONTRACT];

View File

@@ -13,7 +13,9 @@ use substreams::{
use substreams_ethereum::pb::eth;
use crate::{
consts::{CRYPTO_SWAP_NG_FACTORY, NEW_SUSD, OLD_SUSD, TRICRYPTO_FACTORY},
consts::{
CONTRACTS_TO_INDEX, NEW_SUSD, OLD_SUSD,
},
pool_changes::emit_eth_deltas,
pool_factories,
pools::emit_specific_pools,
@@ -292,8 +294,7 @@ pub fn map_protocol_changes(
non_component_accounts_store
.get_last(hex::encode(addr))
.is_some() ||
addr.eq(&CRYPTO_SWAP_NG_FACTORY) ||
addr.eq(&TRICRYPTO_FACTORY)
CONTRACTS_TO_INDEX.contains(addr.try_into().expect("address should be 20 bytes long"))
},
&mut transaction_changes,
);

View File

@@ -9,6 +9,7 @@ const PARAMS_SEPERATOR: &str = ",";
#[derive(Debug, Deserialize, PartialEq)]
struct PoolQueryParams {
address: String,
contracts: Option<Vec<String>>,
tx_hash: String,
tokens: Vec<String>,
attribute_keys: Option<Vec<String>>,
@@ -72,8 +73,20 @@ fn create_component(
change: ChangeType::Creation.into(),
})
.collect::<Vec<_>>(),
contracts: vec![hex::decode(pool.address.clone())
.with_context(|| "Pool address was not formatted properly")?],
contracts: pool
.contracts
.clone()
.unwrap_or_default()
.into_iter()
.map(|contract| {
hex::decode(contract)
.with_context(|| "Pool contracts was not formatted properly")
})
.chain(std::iter::once(
hex::decode(&pool.address)
.with_context(|| "Pool address was not formatted properly"),
))
.collect::<Result<Vec<Vec<u8>>>>()?,
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "curve_pool".into(),