fix: contract creation/update tagging (#117)
* chore: add sfrax to rust fmt ignore * fix(substreams-sdk): correctly mark contract creation. Previously we would mark a contract as created if it was created in any transaction in this block. This would lead to some unexpected behavior if the contract was created and updated in the same block but in different transactions. In that case the update would be tagged as creation. * feat: extract asset types for ng factory This will allow us to detect pools with rebasing tokens and blacklist them until we can support them in `tycho-simulation` * fix: correctly index math implementation for twocrypto factory This implementation is immutable and not dynamic. * fix: index cryptopool factory This factory is needed for simulations by pools that have admin fees. * chore: fix build sfrax abi contract * Bump curve version --------- Co-authored-by: zizou <111426680+flopell@users.noreply.github.com> Co-authored-by: tvinagre <tvinagre@gmail.com> Co-authored-by: Thales <thales@datarevenue.com>
This commit is contained in:
@@ -93,21 +93,20 @@ fn extract_contract_changes_generic<
|
||||
}
|
||||
let mut changed_contracts: HashMap<Vec<u8>, InterimContractChange> = HashMap::new();
|
||||
|
||||
// Collect all accounts created in this block
|
||||
let created_accounts: HashMap<_, _> = block
|
||||
block
|
||||
.transactions()
|
||||
.flat_map(|tx| {
|
||||
tx.calls.iter().flat_map(|call| {
|
||||
.for_each(|block_tx| {
|
||||
// Collect all accounts created in this tx
|
||||
let created_accounts: HashMap<_, _> = block_tx
|
||||
.calls
|
||||
.iter()
|
||||
.flat_map(|call| {
|
||||
call.account_creations
|
||||
.iter()
|
||||
.map(|ac| (&ac.account, ac.ordinal))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
block
|
||||
.transactions()
|
||||
.for_each(|block_tx| {
|
||||
let mut storage_changes = Vec::new();
|
||||
let mut balance_changes = Vec::new();
|
||||
let mut code_changes = Vec::new();
|
||||
|
||||
@@ -20,7 +20,8 @@ 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]; 5] = [
|
||||
pub const CONTRACTS_TO_INDEX: [[u8; 20]; 6] = [
|
||||
CRYPTO_POOL_FACTORY,
|
||||
CRYPTO_SWAP_NG_FACTORY,
|
||||
TRICRYPTO_FACTORY,
|
||||
TRICRYPTO_2_LP,
|
||||
|
||||
@@ -4,7 +4,7 @@ use substreams_ethereum::{
|
||||
};
|
||||
|
||||
use crate::abi;
|
||||
use tycho_substreams::prelude::*;
|
||||
use tycho_substreams::{attributes::json_serialize_bigint_list, prelude::*};
|
||||
|
||||
use crate::consts::*;
|
||||
use substreams::scalar::BigInt;
|
||||
@@ -104,7 +104,11 @@ pub fn address_map(
|
||||
index: tx.index.into(),
|
||||
}),
|
||||
tokens,
|
||||
contracts: vec![component_id.into(), pool_added.token.clone()],
|
||||
contracts: vec![
|
||||
component_id.into(),
|
||||
pool_added.token.clone(),
|
||||
CRYPTO_POOL_FACTORY.into(),
|
||||
],
|
||||
static_att: vec![
|
||||
Attribute {
|
||||
name: "pool_type".into(),
|
||||
@@ -475,6 +479,11 @@ pub fn address_map(
|
||||
value: address_to_bytes_with_0x(&CRYPTO_SWAP_NG_FACTORY),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "asset_types".into(),
|
||||
value: json_serialize_bigint_list(&add_pool.asset_types),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
@@ -549,6 +558,11 @@ pub fn address_map(
|
||||
),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
Attribute {
|
||||
name: "asset_type".into(),
|
||||
value: add_pool.asset_type.to_signed_bytes_be(),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: Some(ProtocolType {
|
||||
@@ -850,6 +864,7 @@ pub fn address_map(
|
||||
abi::twocrypto_factory::events::TwocryptoPoolDeployed::match_and_decode(log)
|
||||
{
|
||||
let id = hex::encode(&pool_added.pool);
|
||||
|
||||
Some((
|
||||
ProtocolComponent {
|
||||
id: id.clone(),
|
||||
@@ -906,12 +921,12 @@ pub fn address_map(
|
||||
},
|
||||
Attribute {
|
||||
name: "stateless_contract_addr_1".into(),
|
||||
// Call math_implementation() on TWOCRYPTO_FACTORY
|
||||
value: format!(
|
||||
"call:0x{}:math_implementation()",
|
||||
hex::encode(TWOCRYPTO_FACTORY)
|
||||
)
|
||||
.into(),
|
||||
value: address_to_bytes_with_0x(
|
||||
&pool_added
|
||||
.math
|
||||
.try_into()
|
||||
.unwrap_or([1u8; 20]), // Unexpected issue marker
|
||||
),
|
||||
change: ChangeType::Creation.into(),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
specVersion: v0.1.0
|
||||
package:
|
||||
name: "substreams_curve"
|
||||
version: v0.3.1
|
||||
version: v0.3.2
|
||||
|
||||
protobuf:
|
||||
files:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,7 @@ ignore = [
|
||||
"crates/tycho-substreams/src/pb",
|
||||
"ethereum-balancer-v2/src/abi",
|
||||
"ethereum-sfraxeth/src/abi",
|
||||
"ethereum-sfrax/src/abi",
|
||||
"ethereum-curve/src/abi",
|
||||
"ethereum-uniswap-v2/src/abi",
|
||||
"ethereum-uniswap-v3/src/abi",
|
||||
|
||||
Reference in New Issue
Block a user