Merge pull request #56 from propeller-heads/fp/curve-fixes
Fix Curve after SDKv2 update
This commit is contained in:
@@ -300,6 +300,88 @@ impl ProtocolComponent {
|
|||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if the instance contains all specified attributes.
|
||||||
|
///
|
||||||
|
/// This function verifies whether the `ProtocolComponent` has all the given static attributes.
|
||||||
|
/// Each attribute is represented by a tuple containing a name and a value. The function
|
||||||
|
/// iterates over the provided attributes and checks if they exist in the instance's
|
||||||
|
/// `static_att`.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `attributes` - A slice of tuples where each tuple consists of a `String` representing the
|
||||||
|
/// attribute name and a `Vec<u8>` representing the attribute value.
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// A boolean indicating whether all specified attributes are present in the instance.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// let attributes_to_check = vec![
|
||||||
|
/// ("attribute1".to_string(), vec![1, 2, 3]),
|
||||||
|
/// ("attribute2".to_string(), vec![4, 5, 6]),
|
||||||
|
/// ];
|
||||||
|
///
|
||||||
|
/// let has_all_attributes = instance.has_attributes(&attributes_to_check);
|
||||||
|
/// assert!(has_all_attributes);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Notes
|
||||||
|
///
|
||||||
|
/// - The function assumes that the `static_att` collection contains attributes with a
|
||||||
|
/// `ChangeType` of `Creation` when they are initially added. This is fine because
|
||||||
|
/// `static_att` can't be updated
|
||||||
|
pub fn has_attributes(&self, attributes: &[(&str, Vec<u8>)]) -> bool {
|
||||||
|
attributes.iter().all(|(name, value)| {
|
||||||
|
self.static_att.contains(&Attribute {
|
||||||
|
name: name.to_string(),
|
||||||
|
value: value.clone(),
|
||||||
|
change: ChangeType::Creation.into(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves the value of a specified attribute by name.
|
||||||
|
///
|
||||||
|
/// This function searches the instance's `static_att` collection for an attribute with the
|
||||||
|
/// given name. If found, it returns a copy of the attribute's value. If the attribute is
|
||||||
|
/// not found, it returns `None`.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `name` - A string slice that holds the name of the attribute to be searched.
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// An `Option<Vec<u8>>` containing the attribute value if found, or `None` if the attribute
|
||||||
|
/// does not exist.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// let attribute_name = "attribute1";
|
||||||
|
/// if let Some(value) = instance.get_attribute_value(attribute_name) {
|
||||||
|
/// // Use the attribute value
|
||||||
|
/// println!("Attribute value: {:?}", value);
|
||||||
|
/// } else {
|
||||||
|
/// println!("Attribute not found");
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// # Notes
|
||||||
|
///
|
||||||
|
/// - The function performs a search based on the attribute name and returns the first match
|
||||||
|
/// found. If there are multiple attributes with the same name, only the first one is
|
||||||
|
/// returned.
|
||||||
|
pub fn get_attribute_value(&self, name: &str) -> Option<Vec<u8>> {
|
||||||
|
self.static_att
|
||||||
|
.iter()
|
||||||
|
.find(|attr| attr.name == name)
|
||||||
|
.map(|attr| attr.value.clone())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as `EntityChanges` but ensures attributes are unique by name.
|
/// Same as `EntityChanges` but ensures attributes are unique by name.
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
# Instructions
|
# Instructions
|
||||||
|
|
||||||
The run command for our substream is a little different here due to the inclusion of the dynamic parameters for manually admitted pools.
|
The run command for our substream is a little different here due to the inclusion of the dynamic parameters for manually
|
||||||
|
admitted pools.
|
||||||
|
|
||||||
This command will add extra parameters to the `map_components` module via the `python params.py` script. This embeds directly in the bash/zsh compatible command here. If `python` is not ideal, the script can be easily converted into `bash` but it would require the `jq` executable (I've used AI to convert it just fine in testing).
|
This command will add extra parameters to the `map_components` module via the `python params.py` script. This embeds
|
||||||
|
directly in the bash/zsh compatible command here. If `python` is not ideal, the script can be easily converted into
|
||||||
|
`bash` but it would require the `jq` executable (I've used AI to convert it just fine in testing).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protocol_changes --start-block 11507454 --stop-block +100 -p map_components=`python params.py`
|
$ substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protocol_changes --start-block 11507454 --stop-block +100 -p map_components=`python params.py`
|
||||||
@@ -10,12 +13,14 @@ $ substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protoco
|
|||||||
|
|
||||||
## `params.json`
|
## `params.json`
|
||||||
|
|
||||||
This json file is a top-level array containing objects that describe a specific `ProtocolComponent`. Each object contains the following fields:
|
This json file is a top-level array containing objects that describe a specific `ProtocolComponent`. Each object
|
||||||
|
contains the following fields:
|
||||||
|
|
||||||
- `name`: Just for documentation purposes
|
- `name`: Just for documentation purposes
|
||||||
- `address`: The **lowercase** address of the component
|
- `address`: The **lowercase** address of the component
|
||||||
- `tx_hash`: The hash of the transaction where the component was emitted
|
- `tx_hash`: The hash of the transaction where the component was emitted
|
||||||
- `tokens`: A list of token addresses ordered in the exact same way as the Pool
|
- `tokens`: A list of token addresses ordered in the exact same way as the Pool
|
||||||
- `attributes`: A nested object of key to value that represents the static attributes of the component.
|
- `static_attributes`: A nested object of key to value that represents the static attributes of the component.
|
||||||
|
- `attributes`: A nested object of key to value that represents attributes.
|
||||||
|
|
||||||
Please see the included 3 examples for `3pool`, `steth`, and `tricrypto2`.
|
Please see the included 3 examples for `3pool`, `steth`, and `tricrypto2`.
|
||||||
|
|||||||
@@ -1,143 +1,316 @@
|
|||||||
substreams_yaml_path: ./substreams.yaml
|
substreams_yaml_path: ./substreams.yaml
|
||||||
protocol_type_names:
|
protocol_type_names:
|
||||||
- "curve_pool"
|
- "curve_pool"
|
||||||
adapter_contract: "CurveSwapAdapter.evm.runtime"
|
adapter_contract: "CurveAdapter"
|
||||||
skip_balance_check: false
|
skip_balance_check: true
|
||||||
|
initialized_accounts:
|
||||||
tests:
|
tests:
|
||||||
- name: test_3pool_creation
|
# Unique pool (no factory) 3pool - 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7
|
||||||
|
- name: test_3pool
|
||||||
start_block: 10809470
|
start_block: 10809470
|
||||||
stop_block: 10810226
|
stop_block: 10810226
|
||||||
expected_state:
|
expected_components:
|
||||||
protocol_components:
|
- id: "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
|
||||||
- id: "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
|
tokens:
|
||||||
tokens:
|
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
||||||
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
static_attributes:
|
||||||
static_attributes:
|
factory_name: "0x6e61" # na
|
||||||
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
name: "0x33706f6f6c" # 3pool
|
||||||
- name: test_steth_creation
|
factory: "0x307830303030303030303030303030303030303030303030303030303030303030303030303030303030" # 0x0000000000000000000000000000000000000000
|
||||||
|
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# Unique pool (no factory) steth - 0xdc24316b9ae028f1497c275eb9192a3ea0f67022
|
||||||
|
- name: test_steth
|
||||||
start_block: 11592550
|
start_block: 11592550
|
||||||
stop_block: 11595553
|
stop_block: 11595553
|
||||||
expected_state:
|
expected_components:
|
||||||
protocol_components:
|
- id: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022"
|
||||||
- id: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022"
|
tokens:
|
||||||
tokens:
|
- "0x0000000000000000000000000000000000000000"
|
||||||
- "0x0000000000000000000000000000000000000000"
|
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
||||||
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
static_attributes:
|
||||||
static_attributes:
|
factory: "0x307830303030303030303030303030303030303030303030303030303030303030303030303030303030" # 0x0000000000000000000000000000000000000000
|
||||||
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
name: "0x7374657468" # steth
|
||||||
- name: test_crypto_swap_ng_factory_plain_pool_creation
|
factory_name: "0x6e61" # na
|
||||||
start_block: 19355220
|
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
||||||
stop_block: 19356225
|
skip_simulation: false
|
||||||
expected_state:
|
|
||||||
protocol_components:
|
# Unique pool (no factory) tricrypto2 - 0xd51a44d3fae010294c616388b506acda1bfaae46
|
||||||
- id: "0xeeda34a377dd0ca676b9511ee1324974fa8d980d"
|
- name: test_tricrypto2
|
||||||
tokens:
|
start_block: 12821118 #This pool was created at 12821148, but it requires some contracts that were created shortly before.
|
||||||
- "0xd9a442856c234a39a81a089c06451ebaa4306a72"
|
stop_block: 12831387
|
||||||
- "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
|
expected_components:
|
||||||
static_attributes:
|
- id: "0xd51a44d3fae010294c616388b506acda1bfaae46"
|
||||||
creation_tx: "0x0e2bad5695d4ff8ebbaf668674a24bdcc4843da44933d947f2a454fd731da3c1"
|
tokens:
|
||||||
- name: test_crypto_swap_ng_factory_meta_pool_creation
|
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
|
- "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
|
||||||
|
- "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||||
|
static_attributes:
|
||||||
|
factory: "0x307830303030303030303030303030303030303030303030303030303030303030303030303030303030" # 0x0000000000000000000000000000000000000000
|
||||||
|
factory_name: "0x6e61" # na
|
||||||
|
name: "0x74726963727970746f32" # tricrypto2
|
||||||
|
creation_tx: "0xdafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# Unique pool (no factory) susd - 0xa5407eae9ba41422680e2e00537571bcc53efbfd
|
||||||
|
- name: test_susd
|
||||||
|
start_block: 9906598
|
||||||
|
stop_block: 9907338
|
||||||
|
expected_components:
|
||||||
|
- id: "0xa5407eae9ba41422680e2e00537571bcc53efbfd"
|
||||||
|
tokens:
|
||||||
|
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
||||||
|
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
|
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
|
- "0x57ab1ec28d129707052df4df418d58a2d46d5f51"
|
||||||
|
static_attributes:
|
||||||
|
factory: "0x307830303030303030303030303030303030303030303030303030303030303030303030303030303030" # 0x0000000000000000000000000000000000000000
|
||||||
|
factory_name: "0x6e61" # na
|
||||||
|
name: "0x73757364" # susd
|
||||||
|
creation_tx: "0x51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# Unique pool (no factory) fraxusdc - 0xdcef968d416a41cdac0ed8702fac8128a64241a2
|
||||||
|
- name: test_fraxusdc
|
||||||
|
start_block: 14939588
|
||||||
|
stop_block: 14939712
|
||||||
|
expected_components:
|
||||||
|
- id: "0xdcef968d416a41cdac0ed8702fac8128a64241a2"
|
||||||
|
tokens:
|
||||||
|
- "0x853d955acef822db058eb8505911ed77f175b99e"
|
||||||
|
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
|
static_attributes:
|
||||||
|
name: "0x6672617875736463" # fraxusdc
|
||||||
|
factory_name: "0x6e61" # na
|
||||||
|
factory: "0x307830303030303030303030303030303030303030303030303030303030303030303030303030303030" # 0x0000000000000000000000000000000000000000
|
||||||
|
creation_tx: "0x1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# CryptoSwapNG factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf - PlainPool
|
||||||
|
- name: test_crypto_swap_ng_factory_plain_pool
|
||||||
|
start_block: 18580701
|
||||||
|
stop_block: 18614742
|
||||||
|
initialized_accounts:
|
||||||
|
- "0x6a8cbed756804b16e05e741edabd5cb544ae21bf"
|
||||||
|
- "0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963" # Needed by another component that is created within this block range
|
||||||
|
- "0xc4ad29ba4b3c580e6d59105fff484999997675ff" # Needed by another component that is created within this block range
|
||||||
|
- "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
|
||||||
|
expected_components:
|
||||||
|
- id: "0x02950460E2b9529D0E00284A5fA2d7bDF3fA4d72"
|
||||||
|
tokens:
|
||||||
|
- "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3"
|
||||||
|
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
||||||
|
static_attributes:
|
||||||
|
factory: "0x307836613863626564373536383034623136653035653734316564616264356362353434616532316266" # 0x6a8cbed756804b16e05e741edabd5cb544ae21bf
|
||||||
|
factory_name: "0x63727970746f5f737761705f6e675f666163746f7279" # crypto_swap_ng_factory
|
||||||
|
name: "0x757364652d75736463" # usde-usdc
|
||||||
|
pool_type: "0x706c61696e5f706f6f6c" # plain_pool
|
||||||
|
creation_tx: "0x6f4438aa1785589e2170599053a0cdc740d8987746a4b5ad9614b6ab7bb4e550"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# CryptoSwapNG factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf - MetaPool
|
||||||
|
- name: test_crypto_swap_ng_factory_metapool
|
||||||
start_block: 19216042
|
start_block: 19216042
|
||||||
stop_block: 19217045
|
stop_block: 19217045
|
||||||
expected_state:
|
initialized_accounts:
|
||||||
protocol_components:
|
- "0x6a8cbed756804b16e05e741edabd5cb544ae21bf" # Factory, needed for implementations contrats queries
|
||||||
- id: "0xef484de8C07B6e2d732A92B5F78e81B38f99f95E"
|
- "0xa5588f7cdf560811710a2d82d3c9c99769db1dcb" # Base pool of this meta pool
|
||||||
tokens:
|
expected_components:
|
||||||
- "0x865377367054516e17014CcdED1e7d814EDC9ce4"
|
- id: "0xef484de8C07B6e2d732A92B5F78e81B38f99f95E"
|
||||||
- "0xA5588F7cdf560811710A2D82D3C9c99769DB1Dcb"
|
tokens:
|
||||||
static_attributes:
|
- "0x865377367054516e17014CcdED1e7d814EDC9ce4"
|
||||||
creation_tx: "0x3cfeecae1b43086ee5705f89b803e21eb0492d7d5db06c229586db8fc72f5665"
|
- "0xa5588f7cdf560811710a2d82d3c9c99769db1dcb"
|
||||||
- name: test_metapool_factory_metapool_creation
|
static_attributes:
|
||||||
start_block: 18028600
|
factory_name: "0x63727970746f5f737761705f6e675f666163746f7279" # crypto_swap_ng_factory
|
||||||
|
name: "0x646f6c612f667261787079757364" # dola/fraxpyusd
|
||||||
|
pool_type: "0x6d657461706f6f6c" # metapool
|
||||||
|
base_pool: "0x307861353538386637636466353630383131373130613264383264336339633939373639646231646362" # 0xa5588f7cdf560811710a2d82d3c9c99769db1dcb
|
||||||
|
factory: "0x307836613863626564373536383034623136653035653734316564616264356362353434616532316266" # 0x6a8cbed756804b16e05e741edabd5cb544ae21bf
|
||||||
|
creation_tx: "0x3cfeecae1b43086ee5705f89b803e21eb0492d7d5db06c229586db8fc72f5665"
|
||||||
|
skip_simulation: true # Reason: this pool use a base pool which is also one of its tokens, therefore our token override doesn't work here and it fails on transfers
|
||||||
|
|
||||||
|
# Metapool factory 0xB9fC157394Af804a3578134A6585C0dc9cc990d4 - MetaPool
|
||||||
|
- name: test_metapool_factory_metapool
|
||||||
|
start_block: 18028604
|
||||||
stop_block: 18029610
|
stop_block: 18029610
|
||||||
expected_state:
|
initialized_accounts:
|
||||||
protocol_components:
|
- "0xdcef968d416a41cdac0ed8702fac8128a64241a2"
|
||||||
- id: "0x61fA2c947e523F9ABfb8d7e2903A5D5218C119a7"
|
- "0xc4ad29ba4b3c580e6d59105fff484999997675ff" # Needed by another component that is created within this block range
|
||||||
tokens:
|
expected_components:
|
||||||
- "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
- id: "0x61fA2c947e523F9ABfb8d7e2903A5D5218C119a7"
|
||||||
- "0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC"
|
tokens:
|
||||||
static_attributes:
|
- "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
||||||
creation_tx: "0xc9c6b879cbb19f7f26405335c3879c350592d530956878ff172e9efad786c63f"
|
- "0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC"
|
||||||
- name: test_metapool_factory_plainpool_creation
|
static_attributes:
|
||||||
|
name: "0x70617970616c667261786270" # paypalfraxbp
|
||||||
|
factory_name: "0x6d6574615f706f6f6c5f666163746f7279" # meta_pool_factory
|
||||||
|
base_pool: "0x307864636566393638643431366134316364616330656438373032666163383132386136343234316132" # 0xdcfe968d416ac0ed8702fac8128a64241a2
|
||||||
|
factory: "0x307862396663313537333934616638303461333537383133346136353835633064633963633939306434" # 0xb9fc157394af804a3578134a6585c0dcc993099d
|
||||||
|
pool_type: "0x6d657461706f6f6c" # metapool
|
||||||
|
creation_tx: "0xc9c6b879cbb19f7f26405335c3879c350592d530956878ff172e9efad786c63f"
|
||||||
|
skip_simulation: true # Reason: this pool calls `totalSupply()` on the LP token during simulation. But this token is overridden and doesn't have anything for totalSupply
|
||||||
|
|
||||||
|
# Metapool factory 0xB9fC157394Af804a3578134A6585C0dc9cc990d4 - PlainPool
|
||||||
|
- name: test_metapool_factory_plainpool
|
||||||
start_block: 18808555
|
start_block: 18808555
|
||||||
stop_block: 18818577
|
stop_block: 18818577
|
||||||
expected_state:
|
initialized_accounts:
|
||||||
protocol_components:
|
- "0xc4ad29ba4b3c580e6d59105fff484999997675ff" # Needed by another component that is created within this block range
|
||||||
- id: "0xf2DCf6336D8250754B4527f57b275b19c8D5CF88"
|
expected_components:
|
||||||
tokens:
|
- id: "0xf2DCf6336D8250754B4527f57b275b19c8D5CF88"
|
||||||
- "0xe9633C52f4c8B7BDeb08c4A7fE8a5c1B84AFCf67"
|
tokens:
|
||||||
- "0x77E06c9eCCf2E797fd462A92B6D7642EF85b0A44"
|
- "0xe9633C52f4c8B7BDeb08c4A7fE8a5c1B84AFCf67"
|
||||||
static_attributes:
|
- "0x77E06c9eCCf2E797fd462A92B6D7642EF85b0A44"
|
||||||
creation_tx: "0xeb34c90d352f18ffcfe78b7e393e155f0314acf06c54d1ac9996e4ee5a9b4742"
|
static_attributes:
|
||||||
- id: "0x3f67dc2AdBA4B1beB6A48c30AB3AFb1c1440d35B"
|
name: "0x77737474616f2f7774616f" # wsttao/wtao
|
||||||
tokens:
|
factory: "0x307862396663313537333934616638303461333537383133346136353835633064633963633939306434" # 0xb9fc157394af804a3578134a6585c0dcc993099d
|
||||||
- "0xe9633C52f4c8B7BDeb08c4A7fE8a5c1B84AFCf67"
|
factory_name: "0x6d6574615f706f6f6c5f666163746f7279" # meta_pool_factory
|
||||||
- "0x77E06c9eCCf2E797fd462A92B6D7642EF85b0A44"
|
pool_type: "0x706c61696e5f706f6f6c" # plain_pool
|
||||||
static_attributes:
|
creation_tx: "0xeb34c90d352f18ffcfe78b7e393e155f0314acf06c54d1ac9996e4ee5a9b4742"
|
||||||
creation_tx: "0x455559b43afaf429c15c1d807fd7f5dd47be30f6411a854499f719b944f4c024"
|
skip_simulation: false
|
||||||
- name: test_cryptopool_factory_creation
|
- id: "0x3f67dc2AdBA4B1beB6A48c30AB3AFb1c1440d35B"
|
||||||
|
tokens:
|
||||||
|
- "0xe9633C52f4c8B7BDeb08c4A7fE8a5c1B84AFCf67"
|
||||||
|
- "0x77E06c9eCCf2E797fd462A92B6D7642EF85b0A44"
|
||||||
|
static_attributes:
|
||||||
|
name: "0x77737474616f2f7774616f" # wsttao/wtao
|
||||||
|
factory: "0x307862396663313537333934616638303461333537383133346136353835633064633963633939306434" # 0xb9fc157394af804a3578134a6585c0dcc993099d
|
||||||
|
factory_name: "0x6d6574615f706f6f6c5f666163746f7279" # meta_pool_factory
|
||||||
|
pool_type: "0x706c61696e5f706f6f6c" # plain_pool
|
||||||
|
creation_tx: "0x455559b43afaf429c15c1d807fd7f5dd47be30f6411a854499f719b944f4c024"
|
||||||
|
skip_simulation: true # Reason: this pool has no liquidity at stop_block
|
||||||
|
|
||||||
|
# CryptoPool factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99
|
||||||
|
- name: test_cryptopool_factory
|
||||||
start_block: 19162590
|
start_block: 19162590
|
||||||
stop_block: 19163633
|
stop_block: 19163633
|
||||||
expected_state:
|
expected_components:
|
||||||
protocol_components:
|
- id: "0x71db3764d6841d8b01dc27c0fd4a66a8a34b2be0" #TODO: ADD TEST THAT USE WETH
|
||||||
- id: "0x71db3764d6841d8b01dc27c0fd4a66a8a34b2be0"
|
tokens:
|
||||||
tokens:
|
- "0x04c154b66cb340f3ae24111cc767e0184ed00cc6"
|
||||||
- "0x04c154b66cb340f3ae24111cc767e0184ed00cc6"
|
- "0x4591dbff62656e7859afe5e45f6f47d3669fbb28"
|
||||||
- "0x4591dbff62656e7859afe5e45f6f47d3669fbb28"
|
static_attributes:
|
||||||
static_attributes:
|
name: "0x343030303030" # 400000
|
||||||
creation_tx: "0xa89c09a7e0dfd84f3a294b8df4f33cc4a623e6d52deee357457afe2591ea596f"
|
pool_type: "0x63727970746f5f706f6f6c" # crypto_pool
|
||||||
- id: "0x6c9Fe53cC13b125d6476E5Ce2b76983bd5b7A112"
|
factory: "0x307866313830353662626433323065393661343865336662663862633036313332323533316161633939" # 0xf18056bbd320e96a48e3fb8bc061322531aacc99
|
||||||
tokens:
|
factory_name: "0x63727970746f5f706f6f6c5f666163746f7279" # crypto_pool_factory
|
||||||
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2"
|
lp_token: "0x6ade6971ca3d90990c30d39c78b0736c7166e07b" # 0x6ade6971ca3d90990c30d39c78b0736c7166e07b
|
||||||
- "0xf951E335afb289353dc249e82926178EaC7DEd78"
|
creation_tx: "0xa89c09a7e0dfd84f3a294b8df4f33cc4a623e6d52deee357457afe2591ea596f"
|
||||||
static_attributes:
|
skip_simulation: false
|
||||||
creation_tx: "0xa5b13d50c56242f7994b8e1339032bb4c6f9ac3af3054d4eae3ce9e32e3c1a50"
|
- id: "0x6c9Fe53cC13b125d6476E5Ce2b76983bd5b7A112"
|
||||||
- name: test_tricrypto_factory_creation
|
tokens:
|
||||||
|
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2"
|
||||||
|
- "0xf951E335afb289353dc249e82926178EaC7DEd78"
|
||||||
|
static_attributes:
|
||||||
|
name: "0x343030303030" # 400000
|
||||||
|
pool_type: "0x63727970746f5f706f6f6c" # crypto_pool
|
||||||
|
factory: "0x307866313830353662626433323065393661343865336662663862633036313332323533316161633939" # 0xf18056bbd320e96a48e3fb8bc061322531aacc99
|
||||||
|
factory_name: "0x63727970746f5f706f6f6c5f666163746f7279" # crypto_pool_factory
|
||||||
|
lp_token: "0x94c4eba4f4b97be8d778f8c27027d676270e87a6" # 0x94c4eba4f4b97be8d778f8c27027d676270e87a6
|
||||||
|
creation_tx: "0xa5b13d50c56242f7994b8e1339032bb4c6f9ac3af3054d4eae3ce9e32e3c1a50"
|
||||||
|
skip_simulation: true # Reason: this pool has no liquidity at stop_block
|
||||||
|
|
||||||
|
# CryptoPool factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 - with ETH
|
||||||
|
- name: test_cryptopool_factory
|
||||||
|
start_block: 19278886
|
||||||
|
stop_block: 19278926
|
||||||
|
expected_components:
|
||||||
|
- id: "0x99e09ee2d6Bb16c0F5ADDfEA649dbB2C1d524624"
|
||||||
|
tokens:
|
||||||
|
- "0x0000000000000000000000000000000000000000"
|
||||||
|
- "0x55296f69f40Ea6d20E478533C15A6B08B654E758"
|
||||||
|
static_attributes:
|
||||||
|
name: "0x343030303030" # 400000
|
||||||
|
pool_type: "0x63727970746f5f706f6f6c" # crypto_pool
|
||||||
|
factory: "0x307866313830353662626433323065393661343865336662663862633036313332323533316161633939" # 0xf18056bbd320e96a48e3fb8bc061322531aacc99
|
||||||
|
factory_name: "0x63727970746f5f706f6f6c5f666163746f7279" # crypto_pool_factory
|
||||||
|
lp_token: "0x393dad6c76d962abba489a77dbf37ae948a4a6ee" # 0x393dad6c76d962abba489a77dbf37ae948a4a6ee
|
||||||
|
creation_tx: "0x52f0f76d97e77579eebd32876de99f656930a99131dc4c4f1dec005786c8782b"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# Tricrypto factory 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963
|
||||||
|
- name: test_tricrypto_factory
|
||||||
start_block: 17371455
|
start_block: 17371455
|
||||||
stop_block: 17374457
|
stop_block: 17374457
|
||||||
expected_state:
|
initialized_accounts:
|
||||||
protocol_components:
|
- "0x0c0e5f2ff0ff18a3be9b835635039256dc4b4963"
|
||||||
- id: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B"
|
- "0xc4ad29ba4b3c580e6d59105fff484999997675ff" # Needed by another component that is created within this block range
|
||||||
tokens:
|
expected_components:
|
||||||
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
- id: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B"
|
||||||
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
|
tokens:
|
||||||
- "0x0000000000000000000000000000000000000000"
|
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
||||||
static_attributes:
|
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
|
||||||
creation_tx: "0x2bd59c19f993b83729fb23498f897a58567c6f0b3ee2f00613ba515a7b19fe23"
|
- "0x0000000000000000000000000000000000000000"
|
||||||
- name: test_twocrypto_factory_creation
|
static_attributes:
|
||||||
start_block: 19760009
|
factory: "0x307830633065356632666630666631386133626539623833353633353033393235366463346234393633" # 0x0c0e5f2ff0ff18a3be9b8356335039256dc4b4963
|
||||||
stop_block: 19763634
|
factory_name: "0x74726963727970746f5f666163746f7279" # tricrypto_factory
|
||||||
expected_state:
|
name: "0x74726963727970746f75736463" # tricrypto_usdc
|
||||||
protocol_components:
|
pool_type: "0x74726963727970746f" # tricrypto
|
||||||
- id: "0x011e998d2d794424de95935d55a6ca81822ecb2b"
|
creation_tx: "0x2bd59c19f993b83729fb23498f897a58567c6f0b3ee2f00613ba515a7b19fe23"
|
||||||
tokens:
|
skip_simulation: false
|
||||||
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
|
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
# Twocrypto factory 0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f
|
||||||
static_attributes:
|
- name: test_twocrypto_factory
|
||||||
creation_tx: "0x412b745a9467aed14f22d2a4cc30651939872d19cee65053f14dd3eb9d488003"
|
start_block: 19692166
|
||||||
- id: "0x19d2b5ce188ca60790755204691e38102749297b"
|
stop_block: 19692232
|
||||||
tokens:
|
initialized_accounts:
|
||||||
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
|
- "0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f" # Factory, needed for implementations contracts queries
|
||||||
- "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
expected_components:
|
||||||
static_attributes:
|
- id: "0x77146B0a1d08B6844376dF6d9da99bA7F1b19e71"
|
||||||
creation_tx: "0x61118d9903f8344e5971d1e7c781f76e855996408dac979d3a4971cefafa6587"
|
tokens:
|
||||||
- id: "0xb3341ca63b6cecf1e1a0d1a99bf0587f4c305652"
|
- "0x55C08ca52497e2f1534B59E2917BF524D4765257"
|
||||||
tokens:
|
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
||||||
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
|
static_attributes:
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
factory: "0x307839386565383531613030616265653064393564303863663463613262646365333261656161663766" # 0x98ee851a00abee0d95d08cf4ca2bdce32aea7f7f
|
||||||
static_attributes:
|
pool_type: "0x74776f63727970746f" # twocrypto
|
||||||
creation_tx: "0xc69332294313b3a8f260e0d5b6a50f0d83707f715fbd8016c32ca61a39ce7ad5"
|
factory_name: "0x74776f63727970746f5f666163746f7279" # twocrypto_factory
|
||||||
- id: "0x99ca0fbaa278cd62e26f0e9b6d167b07d1f0d51b"
|
name: "0x7577752f77657468" # uwu/weth
|
||||||
tokens:
|
creation_tx: "0x61d563e2627437da172fdd60ab54e5cc955fcb75829fd819486e857bac31cad2"
|
||||||
- "0x6c4a8973e6633da2da7187669479c27830c7b1c4"
|
skip_simulation: false
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
||||||
static_attributes:
|
# StableSwap factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d - PlainPool
|
||||||
creation_tx: "0xf2b0c697161f08384c642297e01b3a35f7ec00dd3871d4237a16ae4bb8a1ca99"
|
- name: test_stableswap_factory_plain_pool
|
||||||
- id: "0xde73e407efc75edbafc5bcd62ebb1e7a9b38ebcd"
|
start_block: 17258004
|
||||||
tokens:
|
stop_block: 17260023
|
||||||
- "0x0d86883faf4ffd7aeb116390af37746f45b6f378"
|
initialized_accounts:
|
||||||
- "0x78da5799cf427fee11e9996982f4150ece7a99a7"
|
- "0xc4ad29ba4b3c580e6d59105fff484999997675ff" # Needed by another component that is created within this block range
|
||||||
static_attributes:
|
expected_components:
|
||||||
creation_tx: "0xd4ad7efdcc16d797dd3494ba02b377da4127fd5b1bd25089858b66e5a7e456ab"
|
- id: "0x390f3595bCa2Df7d23783dFd126427CCeb997BF4"
|
||||||
|
tokens:
|
||||||
|
- "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E"
|
||||||
|
- "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
||||||
|
static_attributes:
|
||||||
|
name: "0x6372767573642f75736474" # crvusd/usdt
|
||||||
|
pool_type: "0x706c61696e5f706f6f6c" # plain_pool
|
||||||
|
factory: "0x307834663838343661653933383062393064326537316435653364303432646666336537656262343064" # 0x4f8846ae9380b90d2e71d5e3d042dff3e7ebb40d
|
||||||
|
factory_name: "0x737461626c655f737761705f666163746f7279" # stable_swap_factory
|
||||||
|
creation_tx: "0x40b25773bf8ea673434277d279af40a85b09072072e7004e9048a2ec0f0dd5a0"
|
||||||
|
skip_simulation: false
|
||||||
|
|
||||||
|
# StableSwap factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d - Metapool
|
||||||
|
# - name: test_stableswap_factory_meta_pool
|
||||||
|
# There was no metapool created from this factory yet.
|
||||||
|
# https://etherscan.io/address/0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d#events search events with topic 0x01f31cd2abdeb4e5e10ba500f2db0f937d9e8c735ab04681925441b4ea37eda5.
|
||||||
|
# related event is MetaPoolDeployed(address,address,uint256,uint256,address)
|
||||||
|
|
||||||
|
- name: test_metapool_factory_old
|
||||||
|
start_block: 11968730
|
||||||
|
stop_block: 12028110
|
||||||
|
initialized_accounts:
|
||||||
|
- "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7" # Linked pool of this metapool
|
||||||
|
expected_components:
|
||||||
|
- id: "0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B"
|
||||||
|
tokens:
|
||||||
|
- "0x853d955aCEf822Db058eb8505911ED77F175b99e"
|
||||||
|
- "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490"
|
||||||
|
static_attributes:
|
||||||
|
factory_name: "0x6d6574615f706f6f6c5f666163746f7279" # meta_pool_factory
|
||||||
|
base_pool: "0x307862656263343437383263376462306131613630636236666539376430623438333033326666316337" # 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7
|
||||||
|
factory: "0x307830393539313538623630343064333264303463333031613732636266643662333965323163396165" # 0x0959158b6040d32d04c301a72cbfd6b39e21c9ae
|
||||||
|
pool_type: "0x6d657461706f6f6c" # metapool
|
||||||
|
name: "0x66726178" # frax
|
||||||
|
creation_tx: "0x1f2a0d4e1c1eca594bd7f27f9952480ccda422c3453e0c5074a63aa46a2ed628"
|
||||||
|
skip_simulation: true # Reason: this pool calls `totalSupply()` on the LP token during simulation. But this token is overridden and doesn't have anything for totalSupply
|
||||||
|
|||||||
@@ -1,51 +1,58 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "3pool",
|
"name": "3pool",
|
||||||
"address": "bebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
|
"address": "bebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
|
||||||
"tx_hash": "20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6",
|
"tx_hash": "20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6",
|
||||||
"tokens": [
|
"tokens": [
|
||||||
"6b175474e89094c44da98b954eedeac495271d0f",
|
"6b175474e89094c44da98b954eedeac495271d0f",
|
||||||
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
||||||
"dac17f958d2ee523a2206206994597c13d831ec7"
|
"dac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "steth",
|
"name": "steth",
|
||||||
"address": "dc24316b9ae028f1497c275eb9192a3ea0f67022",
|
"address": "dc24316b9ae028f1497c275eb9192a3ea0f67022",
|
||||||
"tx_hash": "fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa",
|
"tx_hash": "fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa",
|
||||||
"tokens": [
|
"tokens": [
|
||||||
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
||||||
"ae7ab96520de3a18e5e111b5eaab095312d7fe84"
|
"ae7ab96520de3a18e5e111b5eaab095312d7fe84"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tricrypto2",
|
"name": "tricrypto2",
|
||||||
"address": "d51a44d3fae010294c616388b506acda1bfaae46",
|
"address": "d51a44d3fae010294c616388b506acda1bfaae46",
|
||||||
"tx_hash": "dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138",
|
"contracts": [
|
||||||
"tokens": [
|
"c4ad29ba4b3c580e6d59105fff484999997675ff",
|
||||||
"dac17f958d2ee523a2206206994597c13d831ec7",
|
"40745803c2faa8e8402e2ae935933d07ca8f355c"
|
||||||
"2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
],
|
||||||
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
"tx_hash": "dafb6385ed988ce8aacecfe1d97b38ea5e60b1ebce74d2423f71ddd621680138",
|
||||||
]
|
"tokens": [
|
||||||
},
|
"dac17f958d2ee523a2206206994597c13d831ec7",
|
||||||
{
|
"2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||||
"name": "susd",
|
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||||
"address": "a5407eae9ba41422680e2e00537571bcc53efbfd",
|
],
|
||||||
"tx_hash": "51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2",
|
"attributes": {
|
||||||
"tokens": [
|
"stateless_contract_addr_0": "0x8F68f4810CcE3194B6cB6F3d50fa58c2c9bDD1d5"
|
||||||
"6b175474e89094c44da98b954eedeac495271d0f",
|
|
||||||
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
||||||
"dac17f958d2ee523a2206206994597c13d831ec7",
|
|
||||||
"57ab1ec28d129707052df4df418d58a2d46d5f51"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fraxusdc",
|
|
||||||
"address": "dcef968d416a41cdac0ed8702fac8128a64241a2",
|
|
||||||
"tx_hash": "1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775",
|
|
||||||
"tokens": [
|
|
||||||
"853d955acef822db058eb8505911ed77f175b99e",
|
|
||||||
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "susd",
|
||||||
|
"address": "a5407eae9ba41422680e2e00537571bcc53efbfd",
|
||||||
|
"tx_hash": "51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2",
|
||||||
|
"tokens": [
|
||||||
|
"6b175474e89094c44da98b954eedeac495271d0f",
|
||||||
|
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
||||||
|
"dac17f958d2ee523a2206206994597c13d831ec7",
|
||||||
|
"57ab1ec28d129707052df4df418d58a2d46d5f51"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fraxusdc",
|
||||||
|
"address": "dcef968d416a41cdac0ed8702fac8128a64241a2",
|
||||||
|
"tx_hash": "1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775",
|
||||||
|
"tokens": [
|
||||||
|
"853d955acef822db058eb8505911ed77f175b99e",
|
||||||
|
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
@@ -11,14 +11,21 @@ def encode_json_to_query_params(params: list[dict[str, Any]]):
|
|||||||
try:
|
try:
|
||||||
for i, param in enumerate(params):
|
for i, param in enumerate(params):
|
||||||
address: str = param["address"]
|
address: str = param["address"]
|
||||||
|
contracts: str = param.get("contracts", [])
|
||||||
tx_hash: str = param["tx_hash"]
|
tx_hash: str = param["tx_hash"]
|
||||||
tokens: list[str] = param["tokens"]
|
tokens: list[str] = param["tokens"]
|
||||||
|
static_attributes: dict[str, str] = param.get("static_attributes", {})
|
||||||
|
static_attributes["name"] = param["name"]
|
||||||
|
static_attributes["factory_name"] = "NA"
|
||||||
|
static_attributes["factory"] = EMPTY
|
||||||
attributes: dict[str, str] = param.get("attributes", {})
|
attributes: dict[str, str] = param.get("attributes", {})
|
||||||
attributes["name"] = param["name"]
|
|
||||||
attributes["factory_name"] = "NA"
|
|
||||||
attributes["factory"] = EMPTY
|
|
||||||
|
|
||||||
encoded_address = f"address={address}"
|
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_tx_hash = f"tx_hash={tx_hash}"
|
||||||
encoded_tokens = "&".join([f"tokens[]={token}" for token in tokens])
|
encoded_tokens = "&".join([f"tokens[]={token}" for token in tokens])
|
||||||
encoded_attributes = "&".join(
|
encoded_attributes = "&".join(
|
||||||
@@ -27,8 +34,14 @@ def encode_json_to_query_params(params: list[dict[str, Any]]):
|
|||||||
for key, value in attributes.items()
|
for key, value in attributes.items()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
encoded_static_attributes = "&".join(
|
||||||
|
[
|
||||||
|
f"static_attribute_keys[]={key}&static_attribute_vals[]={value}"
|
||||||
|
for key, value in static_attributes.items()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
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_static_attributes}"
|
||||||
encoded_param = encoded_param.rstrip("&")
|
encoded_param = encoded_param.rstrip("&")
|
||||||
encoded_params.append(encoded_param)
|
encoded_params.append(encoded_param)
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,10 @@ pub const STABLESWAP_FACTORY: [u8; 20] = hex!("4F8846Ae9380B90d2E71D5e3D042dff3E
|
|||||||
// Important addresses
|
// Important addresses
|
||||||
pub const WETH_ADDRESS: [u8; 20] = hex!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");
|
pub const WETH_ADDRESS: [u8; 20] = hex!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");
|
||||||
pub const ETH_ADDRESS: [u8; 20] = hex!("EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE");
|
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];
|
||||||
|
|||||||
@@ -5,12 +5,19 @@ use itertools::Itertools;
|
|||||||
use substreams::{
|
use substreams::{
|
||||||
pb::substreams::StoreDeltas,
|
pb::substreams::StoreDeltas,
|
||||||
scalar::BigInt,
|
scalar::BigInt,
|
||||||
store::{StoreAddBigInt, StoreGet, StoreGetString, StoreNew, StoreSet, StoreSetString},
|
store::{
|
||||||
|
StoreAddBigInt, StoreGet, StoreGetInt64, StoreGetString, StoreNew, StoreSet, StoreSetInt64,
|
||||||
|
StoreSetString,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use substreams_ethereum::pb::eth;
|
use substreams_ethereum::pb::eth;
|
||||||
|
|
||||||
use crate::{pool_changes::emit_eth_deltas, pool_factories, pools::emit_specific_pools};
|
use crate::{
|
||||||
|
consts::{CONTRACTS_TO_INDEX, NEW_SUSD, OLD_SUSD},
|
||||||
|
pool_changes::emit_eth_deltas,
|
||||||
|
pool_factories,
|
||||||
|
pools::emit_specific_pools,
|
||||||
|
};
|
||||||
use tycho_substreams::{
|
use tycho_substreams::{
|
||||||
balances::{extract_balance_deltas_from_tx, store_balance_changes},
|
balances::{extract_balance_deltas_from_tx, store_balance_changes},
|
||||||
contract::extract_contract_changes,
|
contract::extract_contract_changes,
|
||||||
@@ -29,63 +36,69 @@ impl PartialEq for TransactionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_components(
|
// Map all created components and their related entity changes.
|
||||||
params: String,
|
pub fn map_components(params: String, block: eth::v2::Block) -> Result<BlockChanges> {
|
||||||
block: eth::v2::Block,
|
let changes = block
|
||||||
) -> Result<BlockTransactionProtocolComponents> {
|
.transactions()
|
||||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
.filter_map(|tx| {
|
||||||
// We store these as a hashmap by tx hash since we need to agg by tx hash later
|
let mut entity_changes = vec![];
|
||||||
Ok(BlockTransactionProtocolComponents {
|
let mut components = vec![];
|
||||||
tx_components: block
|
|
||||||
.transactions()
|
|
||||||
.filter_map(|tx| {
|
|
||||||
let mut components = tx
|
|
||||||
.logs_with_calls()
|
|
||||||
.filter(|(_, call)| !call.call.state_reverted)
|
|
||||||
.filter_map(|(log, call)| {
|
|
||||||
pool_factories::address_map(
|
|
||||||
call.call
|
|
||||||
.address
|
|
||||||
.as_slice()
|
|
||||||
.try_into()
|
|
||||||
.ok()?, // this shouldn't fail
|
|
||||||
log,
|
|
||||||
call.call,
|
|
||||||
tx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
if let Some(component) = emit_specific_pools(¶ms, tx).expect(
|
for (log, call) in tx
|
||||||
"An unexpected error occured when parsing params for emitting specific pools",
|
.logs_with_calls()
|
||||||
|
.filter(|(_, call)| !call.call.state_reverted)
|
||||||
|
{
|
||||||
|
if let Some((component, mut state)) = pool_factories::address_map(
|
||||||
|
call.call
|
||||||
|
.address
|
||||||
|
.as_slice()
|
||||||
|
.try_into()
|
||||||
|
.ok()?, // this shouldn't fail
|
||||||
|
log,
|
||||||
|
call.call,
|
||||||
|
tx,
|
||||||
) {
|
) {
|
||||||
components.push(component)
|
entity_changes.append(&mut state);
|
||||||
|
components.push(component);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !components.is_empty() {
|
if let Some((component, mut state)) = emit_specific_pools(¶ms, tx).expect(
|
||||||
Some(TransactionProtocolComponents {
|
"An unexpected error occured when parsing params for emitting specific pools",
|
||||||
tx: Some(Transaction {
|
) {
|
||||||
hash: tx.hash.clone(),
|
entity_changes.append(&mut state);
|
||||||
from: tx.from.clone(),
|
components.push(component);
|
||||||
to: tx.to.clone(),
|
}
|
||||||
index: Into::<u64>::into(tx.index),
|
|
||||||
}),
|
if components.is_empty() {
|
||||||
components,
|
None
|
||||||
})
|
} else {
|
||||||
} else {
|
Some(TransactionChanges {
|
||||||
None
|
tx: Some(Transaction {
|
||||||
}
|
hash: tx.hash.clone(),
|
||||||
})
|
from: tx.from.clone(),
|
||||||
.collect::<Vec<_>>(),
|
to: tx.to.clone(),
|
||||||
})
|
index: tx.index.into(),
|
||||||
|
}),
|
||||||
|
contract_changes: vec![],
|
||||||
|
entity_changes,
|
||||||
|
component_changes: components,
|
||||||
|
balance_changes: vec![],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
Ok(BlockChanges { block: None, changes })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Simply stores the `ProtocolComponent`s with the pool id as the key and tokens as the value
|
/// Get result `map_components` and stores the created `ProtocolComponent`s with the pool id as the
|
||||||
|
/// key and tokens as the value
|
||||||
#[substreams::handlers::store]
|
#[substreams::handlers::store]
|
||||||
pub fn store_component_tokens(map: BlockTransactionProtocolComponents, store: StoreSetString) {
|
pub fn store_component_tokens(map: BlockChanges, store: StoreSetString) {
|
||||||
map.tx_components
|
map.changes
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|tx_components| &tx_components.components)
|
.flat_map(|tx_changes| &tx_changes.component_changes)
|
||||||
.for_each(|component| {
|
.for_each(|component| {
|
||||||
store.set(
|
store.set(
|
||||||
0,
|
0,
|
||||||
@@ -99,6 +112,29 @@ pub fn store_component_tokens(map: BlockTransactionProtocolComponents, store: St
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stores contracts required by components, for example LP tokens if they are different from the
|
||||||
|
/// pool.
|
||||||
|
/// This is later used to index them with `extract_contract_changes`
|
||||||
|
#[substreams::handlers::store]
|
||||||
|
pub fn store_non_component_accounts(map: BlockChanges, store: StoreSetInt64) {
|
||||||
|
map.changes
|
||||||
|
.iter()
|
||||||
|
.flat_map(|tx_changes| &tx_changes.component_changes)
|
||||||
|
.for_each(|component| {
|
||||||
|
// Crypto pool factory creates LP token separated from the pool, we need to index it so
|
||||||
|
// we add it to the store if the new protocol component comes from this factory
|
||||||
|
if component.has_attributes(&[
|
||||||
|
("pool_type", "crypto_pool".into()),
|
||||||
|
("factory_name", "crypto_pool_factory".into()),
|
||||||
|
]) {
|
||||||
|
let lp_token = component
|
||||||
|
.get_attribute_value("lp_token")
|
||||||
|
.expect("didn't find lp_token attribute");
|
||||||
|
store.set(0, hex::encode(lp_token), &1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Since the `PoolBalanceChanged` events administer only deltas, we need to leverage a map and a
|
/// Since the `PoolBalanceChanged` 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.
|
/// store to be able to tally up final balances for tokens in a pool.
|
||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
@@ -113,15 +149,29 @@ pub fn map_relative_balances(
|
|||||||
.flat_map(|tx| {
|
.flat_map(|tx| {
|
||||||
emit_eth_deltas(tx, &tokens_store)
|
emit_eth_deltas(tx, &tokens_store)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(extract_balance_deltas_from_tx(tx, |token, transactor| {
|
.chain(
|
||||||
let pool_key = format!("pool:{}", hex::encode(transactor));
|
extract_balance_deltas_from_tx(tx, |token, transactor| {
|
||||||
if let Some(tokens) = tokens_store.get_last(pool_key) {
|
let pool_key = format!("pool:{}", hex::encode(transactor));
|
||||||
let token_id = hex::encode(token);
|
if let Some(tokens) = tokens_store.get_last(pool_key) {
|
||||||
tokens.split(':').any(|t| t == token_id)
|
let token_id = if token == OLD_SUSD {
|
||||||
} else {
|
hex::encode(NEW_SUSD)
|
||||||
false
|
} else {
|
||||||
}
|
hex::encode(token)
|
||||||
}))
|
};
|
||||||
|
tokens.split(':').any(|t| t == token_id)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into_iter()
|
||||||
|
.map(|mut balance| {
|
||||||
|
if balance.token == OLD_SUSD {
|
||||||
|
balance.token = NEW_SUSD.into();
|
||||||
|
}
|
||||||
|
balance
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -150,23 +200,24 @@ pub fn store_balances(deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
|
|||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_protocol_changes(
|
pub fn map_protocol_changes(
|
||||||
block: eth::v2::Block,
|
block: eth::v2::Block,
|
||||||
grouped_components: BlockTransactionProtocolComponents,
|
grouped_components: BlockChanges,
|
||||||
deltas: BlockBalanceDeltas,
|
deltas: BlockBalanceDeltas,
|
||||||
components_store: StoreGetString,
|
components_store: StoreGetString,
|
||||||
|
non_component_accounts_store: StoreGetInt64,
|
||||||
balance_store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store.
|
balance_store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store.
|
||||||
) -> Result<BlockChanges> {
|
) -> Result<BlockChanges> {
|
||||||
// We merge contract changes by transaction (identified by transaction index) making it easy to
|
// We merge contract changes by transaction (identified by transaction index) making it easy to
|
||||||
// sort them at the very end.
|
// sort them at the very end.
|
||||||
let mut transaction_changes: HashMap<_, TransactionChanges> = HashMap::new();
|
let mut transaction_changes: HashMap<_, TransactionChanges> = HashMap::new();
|
||||||
|
|
||||||
// `ProtocolComponents` are gathered from `map_pools_created` which just need a bit of work to
|
// `ProtocolComponents` are gathered with some entity changes from `map_pools_created` which
|
||||||
// convert into `TransactionChanges`
|
// just need a bit of work to convert into `TransactionChanges`
|
||||||
grouped_components
|
grouped_components
|
||||||
.tx_components
|
.changes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(|tx_component| {
|
.for_each(|tx_changes| {
|
||||||
let tx = tx_component.tx.as_ref().unwrap();
|
let tx = tx_changes.tx.as_ref().unwrap();
|
||||||
transaction_changes
|
let transaction_entry = transaction_changes
|
||||||
.entry(tx.index)
|
.entry(tx.index)
|
||||||
.or_insert_with(|| TransactionChanges {
|
.or_insert_with(|| TransactionChanges {
|
||||||
tx: Some(tx.clone()),
|
tx: Some(tx.clone()),
|
||||||
@@ -174,18 +225,23 @@ pub fn map_protocol_changes(
|
|||||||
component_changes: vec![],
|
component_changes: vec![],
|
||||||
balance_changes: vec![],
|
balance_changes: vec![],
|
||||||
entity_changes: vec![],
|
entity_changes: vec![],
|
||||||
})
|
});
|
||||||
|
|
||||||
|
let formated_components: Vec<_> = tx_changes //TODO: format directly at creation
|
||||||
.component_changes
|
.component_changes
|
||||||
.extend_from_slice(
|
.into_iter()
|
||||||
&(tx_component
|
.map(|mut component| {
|
||||||
.components
|
component.id = format!("0x{}", component.id);
|
||||||
.into_iter()
|
component
|
||||||
.map(|mut component| {
|
})
|
||||||
component.id = format!("0x{}", component.id);
|
.collect();
|
||||||
component
|
|
||||||
})
|
transaction_entry
|
||||||
.collect::<Vec<_>>()),
|
.component_changes
|
||||||
);
|
.extend(formated_components);
|
||||||
|
transaction_entry
|
||||||
|
.entity_changes
|
||||||
|
.extend(tx_changes.entity_changes);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Balance changes are gathered by the `StoreDelta` based on `TokenExchange`, etc. creating
|
// Balance changes are gathered by the `StoreDelta` based on `TokenExchange`, etc. creating
|
||||||
@@ -242,7 +298,14 @@ pub fn map_protocol_changes(
|
|||||||
|addr| {
|
|addr| {
|
||||||
components_store
|
components_store
|
||||||
.get_last(format!("pool:{0}", hex::encode(addr)))
|
.get_last(format!("pool:{0}", hex::encode(addr)))
|
||||||
.is_some()
|
.is_some() ||
|
||||||
|
non_component_accounts_store
|
||||||
|
.get_last(hex::encode(addr))
|
||||||
|
.is_some() ||
|
||||||
|
CONTRACTS_TO_INDEX.contains(
|
||||||
|
addr.try_into()
|
||||||
|
.expect("address should be 20 bytes long"),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
&mut transaction_changes,
|
&mut transaction_changes,
|
||||||
);
|
);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,11 @@ const PARAMS_SEPERATOR: &str = ",";
|
|||||||
#[derive(Debug, Deserialize, PartialEq)]
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
struct PoolQueryParams {
|
struct PoolQueryParams {
|
||||||
address: String,
|
address: String,
|
||||||
|
contracts: Option<Vec<String>>,
|
||||||
tx_hash: String,
|
tx_hash: String,
|
||||||
tokens: Vec<String>,
|
tokens: Vec<String>,
|
||||||
|
static_attribute_keys: Option<Vec<String>>,
|
||||||
|
static_attribute_vals: Option<Vec<String>>,
|
||||||
attribute_keys: Option<Vec<String>>,
|
attribute_keys: Option<Vec<String>>,
|
||||||
attribute_vals: Option<Vec<String>>,
|
attribute_vals: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
@@ -31,7 +34,7 @@ struct PoolQueryParams {
|
|||||||
pub fn emit_specific_pools(
|
pub fn emit_specific_pools(
|
||||||
params: &str,
|
params: &str,
|
||||||
tx: &TransactionTrace,
|
tx: &TransactionTrace,
|
||||||
) -> Result<Option<ProtocolComponent>> {
|
) -> Result<Option<(ProtocolComponent, Vec<EntityChanges>)>> {
|
||||||
let pools = parse_params(params)?;
|
let pools = parse_params(params)?;
|
||||||
create_component(tx, pools)
|
create_component(tx, pools)
|
||||||
}
|
}
|
||||||
@@ -39,49 +42,81 @@ pub fn emit_specific_pools(
|
|||||||
fn create_component(
|
fn create_component(
|
||||||
tx: &TransactionTrace,
|
tx: &TransactionTrace,
|
||||||
pools: HashMap<String, PoolQueryParams>,
|
pools: HashMap<String, PoolQueryParams>,
|
||||||
) -> Result<Option<ProtocolComponent>> {
|
) -> Result<Option<(ProtocolComponent, Vec<EntityChanges>)>> {
|
||||||
let encoded_hash = hex::encode(tx.hash.clone());
|
let encoded_hash = hex::encode(tx.hash.clone());
|
||||||
if let Some(pool) = pools.get(&encoded_hash) {
|
if let Some(pool) = pools.get(&encoded_hash) {
|
||||||
Ok(Some(ProtocolComponent {
|
Ok(Some((
|
||||||
id: pool.address.clone(),
|
ProtocolComponent {
|
||||||
tx: Some(Transaction {
|
id: pool.address.clone(),
|
||||||
to: tx.to.clone(),
|
tx: Some(Transaction {
|
||||||
from: tx.from.clone(),
|
to: tx.to.clone(),
|
||||||
hash: tx.hash.clone(),
|
from: tx.from.clone(),
|
||||||
index: tx.index.into(),
|
hash: tx.hash.clone(),
|
||||||
}),
|
index: tx.index.into(),
|
||||||
tokens: pool
|
}),
|
||||||
.tokens
|
tokens: pool
|
||||||
|
.tokens
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.map(|token| Result::Ok(hex::decode(token)?))
|
||||||
|
.collect::<Result<Vec<_>>>()
|
||||||
|
.with_context(|| "Token addresses were not formatted properly")?,
|
||||||
|
static_att: zip(
|
||||||
|
pool.static_attribute_keys
|
||||||
|
.clone()
|
||||||
|
.unwrap_or(vec![]),
|
||||||
|
pool.static_attribute_vals
|
||||||
|
.clone()
|
||||||
|
.unwrap_or(vec![]),
|
||||||
|
)
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.map(|(key, value)| Attribute {
|
||||||
.map(|token| Result::Ok(hex::decode(token)?))
|
name: key,
|
||||||
.collect::<Result<Vec<_>>>()
|
value: value.into(),
|
||||||
.with_context(|| "Token addresses were not formatted properly")?,
|
change: ChangeType::Creation.into(),
|
||||||
static_att: zip(
|
})
|
||||||
pool.attribute_keys
|
.collect::<Vec<_>>(),
|
||||||
|
contracts: pool
|
||||||
|
.contracts
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or(vec![]),
|
.unwrap_or_default()
|
||||||
pool.attribute_vals
|
.into_iter()
|
||||||
.clone()
|
.map(|contract| {
|
||||||
.unwrap_or(vec![]),
|
hex::decode(contract)
|
||||||
)
|
.with_context(|| "Pool contracts was not formatted properly")
|
||||||
.clone()
|
})
|
||||||
.map(|(key, value)| Attribute {
|
.chain(std::iter::once(
|
||||||
name: key,
|
hex::decode(&pool.address)
|
||||||
value: value.into(),
|
.with_context(|| "Pool address was not formatted properly"),
|
||||||
|
))
|
||||||
|
.collect::<Result<Vec<Vec<u8>>>>()?,
|
||||||
change: ChangeType::Creation.into(),
|
change: ChangeType::Creation.into(),
|
||||||
})
|
protocol_type: Some(ProtocolType {
|
||||||
.collect::<Vec<_>>(),
|
name: "curve_pool".into(),
|
||||||
contracts: vec![hex::decode(pool.address.clone())
|
financial_type: FinancialType::Swap.into(),
|
||||||
.with_context(|| "Pool address was not formatted properly")?],
|
attribute_schema: Vec::new(),
|
||||||
change: ChangeType::Creation.into(),
|
implementation_type: ImplementationType::Vm.into(),
|
||||||
protocol_type: Some(ProtocolType {
|
}),
|
||||||
name: "curve_pool".into(),
|
},
|
||||||
financial_type: FinancialType::Swap.into(),
|
vec![EntityChanges {
|
||||||
attribute_schema: Vec::new(),
|
component_id: format!("0x{}", pool.address.clone()),
|
||||||
implementation_type: ImplementationType::Vm.into(),
|
attributes: zip(
|
||||||
}),
|
pool.attribute_keys
|
||||||
}))
|
.clone()
|
||||||
|
.unwrap_or(vec![]),
|
||||||
|
pool.attribute_vals
|
||||||
|
.clone()
|
||||||
|
.unwrap_or(vec![]),
|
||||||
|
)
|
||||||
|
.clone()
|
||||||
|
.map(|(key, value)| Attribute {
|
||||||
|
name: key,
|
||||||
|
value: value.into(),
|
||||||
|
change: ChangeType::Creation.into(),
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
}],
|
||||||
|
)))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
@@ -113,6 +148,7 @@ mod tests {
|
|||||||
"0xb71a66c1d93c525a2dd19a8db0da19e65be04f36e733af7f03e3c9dff41aa16a".to_string(),
|
"0xb71a66c1d93c525a2dd19a8db0da19e65be04f36e733af7f03e3c9dff41aa16a".to_string(),
|
||||||
PoolQueryParams {
|
PoolQueryParams {
|
||||||
address: "0x5F890841f657d90E081bAbdB532A05996Af79Fe6".to_string(),
|
address: "0x5F890841f657d90E081bAbdB532A05996Af79Fe6".to_string(),
|
||||||
|
contracts: None,
|
||||||
tx_hash: "0xb71a66c1d93c525a2dd19a8db0da19e65be04f36e733af7f03e3c9dff41aa16a"
|
tx_hash: "0xb71a66c1d93c525a2dd19a8db0da19e65be04f36e733af7f03e3c9dff41aa16a"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
tokens: vec![
|
tokens: vec![
|
||||||
@@ -120,6 +156,8 @@ mod tests {
|
|||||||
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48".to_string(),
|
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48".to_string(),
|
||||||
"0xdac17f958d2ee523a2206206994597c13d831ec7".to_string(),
|
"0xdac17f958d2ee523a2206206994597c13d831ec7".to_string(),
|
||||||
],
|
],
|
||||||
|
static_attribute_keys: None,
|
||||||
|
static_attribute_vals: None,
|
||||||
attribute_keys: Some(vec!["key1".to_string()]),
|
attribute_keys: Some(vec!["key1".to_string()]),
|
||||||
attribute_vals: Some(vec!["val1".to_string()]),
|
attribute_vals: Some(vec!["val1".to_string()]),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ binaries:
|
|||||||
modules:
|
modules:
|
||||||
- name: map_components
|
- name: map_components
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 9906598
|
initialBlock: 9906598 # Creation of first Curve pool 0xa5407eae9ba41422680e2e00537571bcc53efbfd
|
||||||
inputs:
|
inputs:
|
||||||
- params: string
|
- params: string
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
output:
|
output:
|
||||||
type: proto:tycho.evm.v1.BlockTransactionProtocolComponents
|
type: proto:tycho.evm.v1.BlockChanges
|
||||||
|
|
||||||
- name: store_component_tokens
|
- name: store_component_tokens
|
||||||
kind: store
|
kind: store
|
||||||
@@ -35,9 +35,17 @@ modules:
|
|||||||
inputs:
|
inputs:
|
||||||
- map: map_components
|
- map: map_components
|
||||||
|
|
||||||
|
- name: store_non_component_accounts
|
||||||
|
kind: store
|
||||||
|
initialBlock: 9906598
|
||||||
|
updatePolicy: set
|
||||||
|
valueType: int64
|
||||||
|
inputs:
|
||||||
|
- map: map_components
|
||||||
|
|
||||||
- name: map_relative_balances
|
- name: map_relative_balances
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 9906598 # An arbitrary block that should change based on your requirements
|
initialBlock: 9906598
|
||||||
inputs:
|
inputs:
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
- store: store_component_tokens
|
- store: store_component_tokens
|
||||||
@@ -60,10 +68,11 @@ modules:
|
|||||||
- map: map_components
|
- map: map_components
|
||||||
- map: map_relative_balances
|
- map: map_relative_balances
|
||||||
- store: store_component_tokens
|
- store: store_component_tokens
|
||||||
|
- store: store_non_component_accounts
|
||||||
- store: store_balances
|
- store: store_balances
|
||||||
mode: deltas # This is the key property that simplifies `BalanceChange` handling
|
mode: deltas # This is the key property that simplifies `BalanceChange` handling
|
||||||
output:
|
output:
|
||||||
type: proto:tycho.evm.v1.BlockChanges
|
type: proto:tycho.evm.v1.BlockChanges
|
||||||
|
|
||||||
params:
|
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&&static_attribute_keys[]=name&static_attribute_vals[]=3pool&static_attribute_keys[]=factory_name&static_attribute_vals[]=NA&static_attribute_keys[]=factory&static_attribute_vals[]=0x0000000000000000000000000000000000000000,address=dc24316b9ae028f1497c275eb9192a3ea0f67022&tx_hash=fac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa&tokens[]=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokens[]=ae7ab96520de3a18e5e111b5eaab095312d7fe84&&static_attribute_keys[]=name&static_attribute_vals[]=steth&static_attribute_keys[]=factory_name&static_attribute_vals[]=NA&static_attribute_keys[]=factory&static_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&static_attribute_keys[]=name&static_attribute_vals[]=tricrypto2&static_attribute_keys[]=factory_name&static_attribute_vals[]=NA&static_attribute_keys[]=factory&static_attribute_vals[]=0x0000000000000000000000000000000000000000,address=a5407eae9ba41422680e2e00537571bcc53efbfd&tx_hash=51aca4a03a395de8855fa2ca59b7febe520c2a223e69c502066162f7c1a95ec2&tokens[]=6b175474e89094c44da98b954eedeac495271d0f&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&tokens[]=dac17f958d2ee523a2206206994597c13d831ec7&tokens[]=57ab1ec28d129707052df4df418d58a2d46d5f51&&static_attribute_keys[]=name&static_attribute_vals[]=susd&static_attribute_keys[]=factory_name&static_attribute_vals[]=NA&static_attribute_keys[]=factory&static_attribute_vals[]=0x0000000000000000000000000000000000000000,address=dcef968d416a41cdac0ed8702fac8128a64241a2&tx_hash=1f4254004ce9e19d4eb742ee5a69d30f29085902d976f73e97c44150225ef775&tokens[]=853d955acef822db058eb8505911ed77f175b99e&tokens[]=a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&&static_attribute_keys[]=name&static_attribute_vals[]=fraxusdc&static_attribute_keys[]=factory_name&static_attribute_vals[]=NA&static_attribute_keys[]=factory&static_attribute_vals[]=0x0000000000000000000000000000000000000000"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class ProtocolComponentExpectation(BaseModel):
|
|||||||
colorize_diff(diff) if colorize_output else "\n".join(diff)
|
colorize_diff(diff) if colorize_output else "\n".join(diff)
|
||||||
)
|
)
|
||||||
differences.append(
|
differences.append(
|
||||||
f"Field '{field_name}' mismatch:\n{highlighted_diff}"
|
f"Field '{field_name}' mismatch for {self.id}:\n{highlighted_diff}"
|
||||||
)
|
)
|
||||||
if not differences:
|
if not differences:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user