From 753d20fe51530414e1badc5dafbcd14bc8815bfd Mon Sep 17 00:00:00 2001 From: jmcph4 Date: Wed, 12 Jun 2024 16:27:10 +1000 Subject: [PATCH] Improve documentation comments --- src/main.rs | 7 +++++++ src/spec.rs | 8 ++++++++ src/variant.rs | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/main.rs b/src/main.rs index a6db120..ea0e50c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,14 +12,21 @@ use crate::spec::CheckpointSpecification; mod spec; mod variant; +/// URL of the default RPC provider const DEFAULT_RPC_URL: &str = "https://eth.merkle.io"; + +/// Default filename for output checkpoint file const DEFAULT_OUTPUT_PATH: &str = ".cfmms-checkpoint.json"; +/// CLI parameters #[derive(Parser)] struct Opts { + /// URL to the Ethereum RPC provider #[clap(short, long)] rpc: Option, + /// Path to the input CSV file r#in: PathBuf, + /// Path to write the output checkpoint JSON file to out: Option, } diff --git a/src/spec.rs b/src/spec.rs index c2e2810..f4b7da9 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -1,3 +1,4 @@ +//! Logic and types for checkpoint specification use std::{path::Path, sync::Arc}; use alloy::primitives::{Address, BlockNumber}; @@ -14,8 +15,10 @@ use serde::{Deserialize, Serialize}; use crate::variant::AmmVariant; +/// Default fee for AMM pools pub const DEFAULT_FEE: u32 = 300; +/// Represents a single row of CSV #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SpecificationEntry { pub variant: AmmVariant, @@ -25,6 +28,7 @@ pub struct SpecificationEntry { } impl SpecificationEntry { + /// Retrieves both the associated AMM factory and pool for this [`SpecificationEntry`] async fn fetch( &self, provider: Arc, @@ -63,10 +67,12 @@ impl SpecificationEntry { } } +/// Represents a sequence of CSV rows #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CheckpointSpecification(pub Vec); impl CheckpointSpecification { + /// Reads a [`CheckpointSpecification`] from disk pub fn load

(path: P) -> eyre::Result where P: AsRef, @@ -78,6 +84,8 @@ impl CheckpointSpecification { )) } + /// Retrieves the entire set of AMM factories and pools specified in this + /// [`CheckpointSpecification`] pub async fn fetch( &self, provider: Arc, diff --git a/src/variant.rs b/src/variant.rs index c65b973..3c35163 100644 --- a/src/variant.rs +++ b/src/variant.rs @@ -1,5 +1,7 @@ +//! Types for handling types of AMMs use serde::{Deserialize, Serialize}; +/// Represents a type of AMM pool #[derive(Copy, Clone, Debug, Deserialize, Serialize)] pub enum AmmVariant { UniswapV2,