fix(curve): index tricrypto2 dependencies
This commit is contained in:
@@ -34,7 +34,7 @@ tests:
|
||||
skip_simulation: false
|
||||
|
||||
- name: test_tricrypto2
|
||||
start_block: 12821148
|
||||
start_block: 12821118 #This pool was created at 12821148, but it requires some contracts that were created shortly before.
|
||||
stop_block: 12831387
|
||||
expected_state:
|
||||
protocol_components:
|
||||
@@ -45,7 +45,7 @@ tests:
|
||||
- "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
static_attributes:
|
||||
creation_tx: "0xdafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138"
|
||||
skip_simulation: true #TODO: investigate this failure
|
||||
skip_simulation: false
|
||||
|
||||
- name: test_susd
|
||||
start_block: 9906598
|
||||
|
||||
@@ -21,12 +21,19 @@
|
||||
{
|
||||
"name": "tricrypto2",
|
||||
"address": "d51a44d3fae010294c616388b506acda1bfaae46",
|
||||
"contracts": [
|
||||
"c4ad29ba4b3c580e6d59105fff484999997675ff",
|
||||
"40745803c2faa8e8402e2ae935933d07ca8f355c"
|
||||
],
|
||||
"tx_hash": "dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138",
|
||||
"tokens": [
|
||||
"dac17f958d2ee523a2206206994597c13d831ec7",
|
||||
"2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
]
|
||||
],
|
||||
"attributes": {
|
||||
"stateless_contract_addr_0": "0x8F68f4810CcE3194B6cB6F3d50fa58c2c9bDD1d5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "susd",
|
||||
|
||||
@@ -11,6 +11,7 @@ def encode_json_to_query_params(params: list[dict[str, Any]]):
|
||||
try:
|
||||
for i, param in enumerate(params):
|
||||
address: str = param["address"]
|
||||
contracts: str = param.get("contracts", [])
|
||||
tx_hash: str = param["tx_hash"]
|
||||
tokens: list[str] = param["tokens"]
|
||||
attributes: dict[str, str] = param.get("attributes", {})
|
||||
@@ -19,6 +20,8 @@ def encode_json_to_query_params(params: list[dict[str, Any]]):
|
||||
attributes["factory"] = EMPTY
|
||||
|
||||
encoded_address = f"address={address}"
|
||||
encoded_contracts = "&" + "&".join(
|
||||
[f"contracts[]={contract}" for contract in contracts]) if contracts else ''
|
||||
encoded_tx_hash = f"tx_hash={tx_hash}"
|
||||
encoded_tokens = "&".join([f"tokens[]={token}" for token in tokens])
|
||||
encoded_attributes = "&".join(
|
||||
@@ -28,7 +31,7 @@ def encode_json_to_query_params(params: list[dict[str, Any]]):
|
||||
]
|
||||
)
|
||||
|
||||
encoded_param = f"{encoded_address}&{encoded_tx_hash}&{encoded_tokens}&{encoded_attributes}"
|
||||
encoded_param = f"{encoded_address}{encoded_contracts}&{encoded_tx_hash}&{encoded_tokens}&{encoded_attributes}"
|
||||
encoded_param = encoded_param.rstrip("&")
|
||||
encoded_params.append(encoded_param)
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -75,4 +75,4 @@ modules:
|
||||
type: proto:tycho.evm.v1.BlockChanges
|
||||
|
||||
params:
|
||||
map_components: "address=bebc44782c7db0a1a60cb6fe97d0b483032ff1c7&tx_hash=20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6&tokens[]=6b175474e89094c44da98b954eedeac495271d0f&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&attribute_keys[]=name&attribute_vals[]=3pool&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=dc24316b9ae028f1497c275eb9192a3ea0f67022&tx_hash=fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa&tokens[]=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokens[]=ae7ab96520de3a18e5e111b5eaab095312d7fe84&attribute_keys[]=name&attribute_vals[]=steth&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=d51a44d3fae010294c616388b506acda1bfaae46&tx_hash=dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&tokens[]=2260fac5e5542a773aa44fbcfedf7c193bc2c599&tokens[]=c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&attribute_keys[]=name&attribute_vals[]=tricrypto2&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=a5407eae9ba41422680e2e00537571bcc53efbfd&tx_hash=51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2&tokens[]=6b175474e89094c44da98b954eedeac495271d0f&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&tokens[]=57ab1ec28d129707052df4df418d58a2d46d5f51&attribute_keys[]=name&attribute_vals[]=susd&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=dcef968d416a41cdac0ed8702fac8128a64241a2&tx_hash=1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775&tokens[]=853d955acef822db058eb8505911ed77f175b99e&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&attribute_keys[]=name&attribute_vals[]=fraxusdc&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000"
|
||||
map_components: "address=bebc44782c7db0a1a60cb6fe97d0b483032ff1c7&tx_hash=20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6&tokens[]=6b175474e89094c44da98b954eedeac495271d0f&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&attribute_keys[]=name&attribute_vals[]=3pool&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=dc24316b9ae028f1497c275eb9192a3ea0f67022&tx_hash=fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa&tokens[]=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokens[]=ae7ab96520de3a18e5e111b5eaab095312d7fe84&attribute_keys[]=name&attribute_vals[]=steth&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=d51a44d3fae010294c616388b506acda1bfaae46&contracts[]=c4ad29ba4b3c580e6d59105fff484999997675ff&contracts[]=40745803c2faa8e8402e2ae935933d07ca8f355c&tx_hash=dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&tokens[]=2260fac5e5542a773aa44fbcfedf7c193bc2c599&tokens[]=c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&attribute_keys[]=stateless_contract_addr_0&attribute_vals[]=0x8F68f4810CcE3194B6cB6F3d50fa58c2c9bDD1d5&attribute_keys[]=name&attribute_vals[]=tricrypto2&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=a5407eae9ba41422680e2e00537571bcc53efbfd&tx_hash=51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2&tokens[]=6b175474e89094c44da98b954eedeac495271d0f&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&tokens[]=57ab1ec28d129707052df4df418d58a2d46d5f51&attribute_keys[]=name&attribute_vals[]=susd&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000,address=dcef968d416a41cdac0ed8702fac8128a64241a2&tx_hash=1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775&tokens[]=853d955acef822db058eb8505911ed77f175b99e&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&attribute_keys[]=name&attribute_vals[]=fraxusdc&attribute_keys[]=factory_name&attribute_vals[]=NA&attribute_keys[]=factory&attribute_vals[]=0x0000000000000000000000000000000000000000"
|
||||
|
||||
Reference in New Issue
Block a user