Update docs

This commit is contained in:
kayibal
2025-02-05 00:23:40 -06:00
committed by Alan Höng
parent 08d2c7a82e
commit 5eb08acf82
2 changed files with 23 additions and 8 deletions

View File

@@ -9,8 +9,8 @@
//! //!
//! ## Alternative Module //! ## Alternative Module
//! If your protocol uses a vault-like contract to manage balances, or if pools are //! If your protocol uses a vault-like contract to manage balances, or if pools are
//! registered within a singleton contract, refer to the `modules_singleton` module //! registered within a singleton contract, refer to the `ethereum-template-singleton`
//! for an appropriate alternative. //! substream for an appropriate alternative.
//! //!
//! ## Warning //! ## Warning
//! This template provides a general framework for indexing a protocol. However, it is //! This template provides a general framework for indexing a protocol. However, it is

View File

@@ -1,5 +1,19 @@
//! Template for Protocols with singleton contract //! Template for Protocols with singleton contract
//! //!
//! This template provides a starting point for protocols that follow a singleton
//! pattern. Usually these protocols employ a fixed set of contracts instead of
//! deploying new contracts per component.
//!
//! ## Alternative Module
//! If your protocol uses individual contracts deployed with a factory to manage
//! components and balances, refer to the `ethereum-template-factory` substream for an
//! appropriate alternative.
//!
//! ## Warning
//! This template provides a general framework for indexing a protocol. However, it is
//! likely that you will need to adapt the steps to suit your specific use case. Use the
//! provided code with care and ensure you fully understand each step before proceeding
//! with your implementation
//! //!
use std::collections::HashMap; use std::collections::HashMap;
use anyhow::Result; use anyhow::Result;
@@ -73,16 +87,17 @@ fn store_protocol_tokens(map_protocol_components: BlockTransactionProtocolCompon
/// Extracts balance changes per component /// Extracts balance changes per component
/// ///
/// This template function inspects ERC20 transfer events to/from the singleton contract /// This template function inspects ERC20 transfer events to/from the singleton contract
/// to extract balance changes. If a transfer to the component is detected, it's /// to extract balance changes. If a transfer to the component is detected, it's
/// balanced is increased and if a balance from the component is detected its balance /// balanced is increased and if a balance from the component is detected its balance
/// is decreased. /// is decreased.
/// ///
/// ## Note: /// ## Note:
/// Changes are necessary if your protocol uses native ETH or your component burns or /// - If your protocol emits events that let you calculate balance deltas more
/// mints tokens without emitting transfer events. /// efficiently you may want to use those instead of raw transfers.
/// /// - Changes are necessary if your protocol uses native ETH or your component burns or
/// You may want to ignore LP tokens if your protocol emits transfer events for these /// mints tokens without emitting transfer events.
/// here. /// - You may want to ignore LP tokens if your protocol emits transfer events for these
/// here.
#[substreams::handlers::map] #[substreams::handlers::map]
fn map_relative_component_balance(params: String, block: eth::v2::Block, store: StoreGetInt64) -> Result<BlockBalanceDeltas> { fn map_relative_component_balance(params: String, block: eth::v2::Block, store: StoreGetInt64) -> Result<BlockBalanceDeltas> {
let config: DeploymentConfig = serde_qs::from_str(params.as_str())?; let config: DeploymentConfig = serde_qs::from_str(params.as_str())?;