Normalise module names for balancer.
This way the module names are in sync with the gitbook docs.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,3 +11,5 @@ target/
|
|||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
substreams/ethereum-template/Cargo.lock
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use tycho_substreams::{
|
|||||||
const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
||||||
|
|
||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_pools_created(block: eth::v2::Block) -> Result<BlockTransactionProtocolComponents> {
|
pub fn map_components(block: eth::v2::Block) -> Result<BlockTransactionProtocolComponents> {
|
||||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
// 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
|
// We store these as a hashmap by tx hash since we need to agg by tx hash later
|
||||||
Ok(BlockTransactionProtocolComponents {
|
Ok(BlockTransactionProtocolComponents {
|
||||||
@@ -47,7 +47,7 @@ pub fn map_pools_created(block: eth::v2::Block) -> Result<BlockTransactionProtoc
|
|||||||
|
|
||||||
/// Simply stores the `ProtocolComponent`s with the pool id as the key
|
/// Simply stores the `ProtocolComponent`s with the pool id as the key
|
||||||
#[substreams::handlers::store]
|
#[substreams::handlers::store]
|
||||||
pub fn store_pools_created(map: BlockTransactionProtocolComponents, store: StoreAddInt64) {
|
pub fn store_components(map: BlockTransactionProtocolComponents, store: StoreAddInt64) {
|
||||||
store.add_many(
|
store.add_many(
|
||||||
0,
|
0,
|
||||||
&map.tx_components
|
&map.tx_components
|
||||||
@@ -62,7 +62,7 @@ pub fn store_pools_created(map: BlockTransactionProtocolComponents, store: Store
|
|||||||
/// Since the `PoolBalanceChanged` and `Swap` events administer only deltas, we need to leverage a
|
/// 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.
|
/// map and a store to be able to tally up final balances for tokens in a pool.
|
||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_balance_deltas(
|
pub fn map_relative_balances(
|
||||||
block: eth::v2::Block,
|
block: eth::v2::Block,
|
||||||
store: StoreGetInt64,
|
store: StoreGetInt64,
|
||||||
) -> Result<BlockBalanceDeltas, anyhow::Error> {
|
) -> Result<BlockBalanceDeltas, anyhow::Error> {
|
||||||
@@ -133,7 +133,7 @@ pub fn map_balance_deltas(
|
|||||||
/// It's significant to include both the `pool_id` and the `token_id` for each balance delta as the
|
/// 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.
|
/// store key to ensure that there's a unique balance being tallied for each.
|
||||||
#[substreams::handlers::store]
|
#[substreams::handlers::store]
|
||||||
pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
|
pub fn store_balances(deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
|
||||||
tycho_substreams::balances::store_balance_changes(deltas, store);
|
tycho_substreams::balances::store_balance_changes(deltas, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: StoreAddBigInt)
|
|||||||
/// At the very end, the map can easily be sorted by index to ensure the final
|
/// At the very end, the map can easily be sorted by index to ensure the final
|
||||||
/// `BlockContractChanges` is ordered by transactions properly.
|
/// `BlockContractChanges` is ordered by transactions properly.
|
||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_changes(
|
pub fn map_protocol_changes(
|
||||||
block: eth::v2::Block,
|
block: eth::v2::Block,
|
||||||
grouped_components: BlockTransactionProtocolComponents,
|
grouped_components: BlockTransactionProtocolComponents,
|
||||||
deltas: BlockBalanceDeltas,
|
deltas: BlockBalanceDeltas,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ binaries:
|
|||||||
file: ../target/wasm32-unknown-unknown/release/ethereum_balancer.wasm
|
file: ../target/wasm32-unknown-unknown/release/ethereum_balancer.wasm
|
||||||
|
|
||||||
modules:
|
modules:
|
||||||
- name: map_pools_created
|
- name: map_components
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 12369300
|
initialBlock: 12369300
|
||||||
inputs:
|
inputs:
|
||||||
@@ -17,40 +17,40 @@ modules:
|
|||||||
output:
|
output:
|
||||||
type: proto:tycho.evm.v1.GroupedTransactionProtocolComponents
|
type: proto:tycho.evm.v1.GroupedTransactionProtocolComponents
|
||||||
|
|
||||||
- name: store_pools_created
|
- name: store_components
|
||||||
kind: store
|
kind: store
|
||||||
initialBlock: 12369300
|
initialBlock: 12369300
|
||||||
updatePolicy: add
|
updatePolicy: add
|
||||||
valueType: int64
|
valueType: int64
|
||||||
inputs:
|
inputs:
|
||||||
- map: map_pools_created
|
- map: map_components
|
||||||
|
|
||||||
- name: map_balance_deltas
|
- name: map_relative_balances
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 12369300 # An arbitrary block that should change based on your requirements
|
initialBlock: 12369300 # An arbitrary block that should change based on your requirements
|
||||||
inputs:
|
inputs:
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
- store: store_pools_created
|
- store: store_components
|
||||||
output:
|
output:
|
||||||
type: proto:tycho.evm.v1.BalanceDeltas
|
type: proto:tycho.evm.v1.BalanceDeltas
|
||||||
|
|
||||||
- name: store_balance_changes
|
- name: store_balances
|
||||||
kind: store
|
kind: store
|
||||||
initialBlock: 12369300
|
initialBlock: 12369300
|
||||||
updatePolicy: add
|
updatePolicy: add
|
||||||
valueType: bigint
|
valueType: bigint
|
||||||
inputs:
|
inputs:
|
||||||
- map: map_balance_deltas
|
- map: map_relative_balances
|
||||||
|
|
||||||
- name: map_changes
|
- name: map_changes
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 12369300
|
initialBlock: 12369300
|
||||||
inputs:
|
inputs:
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
- map: map_pools_created
|
- map: map_components
|
||||||
- map: map_balance_deltas
|
- map: map_relative_balances
|
||||||
- store: store_pools_created
|
- store: store_components
|
||||||
- store: store_balance_changes
|
- 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.BlockContractChanges
|
type: proto:tycho.evm.v1.BlockContractChanges
|
||||||
|
|||||||
Reference in New Issue
Block a user