Skip to content

Commit

Permalink
Improve documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcph4 committed Jun 12, 2024
1 parent cf815f6 commit 753d20f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Url>,
/// Path to the input CSV file
r#in: PathBuf,
/// Path to write the output checkpoint JSON file to
out: Option<PathBuf>,
}

Expand Down
8 changes: 8 additions & 0 deletions src/spec.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Logic and types for checkpoint specification
use std::{path::Path, sync::Arc};

use alloy::primitives::{Address, BlockNumber};
Expand All @@ -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,
Expand All @@ -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<ReqwestProvider>,
Expand Down Expand Up @@ -63,10 +67,12 @@ impl SpecificationEntry {
}
}

/// Represents a sequence of CSV rows
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CheckpointSpecification(pub Vec<SpecificationEntry>);

impl CheckpointSpecification {
/// Reads a [`CheckpointSpecification`] from disk
pub fn load<P>(path: P) -> eyre::Result<Self>
where
P: AsRef<Path>,
Expand All @@ -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<ReqwestProvider>,
Expand Down
2 changes: 2 additions & 0 deletions src/variant.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 753d20f

Please sign in to comment.