diff --git a/Cargo.toml b/Cargo.toml index 33280bb..95d9d40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,16 @@ [package] name = "mkcheckpoint" -version = "0.1.0" -description = "Generate amms-rs-style checkpoints" +version = "0.2.0" +description = "A small tool for generating state snapshots of AMM pools" edition = "2021" +authors = ["Jack McPherson "] +license = "MIT" +repository = "https://github.com/jmcph4/mkcheckpoint" +readme = "README.md" +keywords = ["blockchain", "ethereum", "cryptocurrency"] +categories = ["cryptography::cryptocurrencies", "development-tools"] + [dependencies] amms = { git = "https://github.com/darkforestry/amms-rs", rev = "7d9980a" } alloy = { git = "https://github.com/alloy-rs/alloy", rev = "dd7a999", features = [ @@ -34,3 +41,7 @@ pretty_env_logger = "0.5.0" tokio = { version = "^1.0", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } url = "2.5.0" + +[[bin]] +name = "mkcheckpoint" + diff --git a/LICENSE b/LICENSE index 296e8a0..3a638e6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Jack McPherson +Copyright (c) 2024-2025 Jack McPherson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index cfd1fb2..62b77e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,63 @@ # mkcheckpoint # -[![asciicast](https://asciinema.org/a/z54IdDpzQepbzRB57RY6av4SU.svg)](https://asciinema.org/a/z54IdDpzQepbzRB57RY6av4SU) - `mkcheckpoint` is a program that generates [`amms-rs`](https://github.com/darkforestry/amms-rs)-style checkpoints from CSV data. +## Installation ## + +``` +$ cargo install mkcheckpoint +``` + +## Usage ## + +``` +$ mkcheckpoint -h +A small tool for generating state snapshots of AMM pools + +Usage: mkcheckpoint [OPTIONS] [OUT] + +Arguments: + Path to the input CSV file + [OUT] Path to write the output checkpoint JSON file to [default: .cfmms-checkpoint.json] + +Options: + -r, --rpc URL to the Ethereum RPC provider [default: https://eth.merkle.io] + -h, --help Print help + -V, --version Print version +``` + +``` +$ cat a_single_pool.csv +variant,factory,factory_created,pool +UniswapV2,0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,0,0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852 +$ mkcheckpoint a_single_pool.csv +$ cat .cfmms-checkpoint.json | jq +{ + "timestamp": 1738535405, + "block_number": 21761814, + "factories": [ + { + "UniswapV2Factory": { + "address": "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f", + "creation_block": 0, + "fee": 300 + } + } + ], + "amms": [ + { + "UniswapV2Pool": { + "address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852", + "token_a": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "token_a_decimals": 18, + "token_b": "0xdac17f958d2ee523a2206206994597c13d831ec7", + "token_b_decimals": 6, + "reserve_0": 10999641383329786000000, + "reserve_1": 31936057989252, + "fee": 300 + } + } + ] +} +``` + diff --git a/src/main.rs b/src/main.rs index 0818e3f..56f4129 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,14 +19,16 @@ const DEFAULT_RPC_URL: &str = "https://eth.merkle.io"; const DEFAULT_OUTPUT_PATH: &str = ".cfmms-checkpoint.json"; /// `mkcheckpoint` is a utility for producing checkpoints of AMM state from CSV data -#[derive(Parser)] +#[derive(Clone, Debug, Parser)] +#[clap(version, about, author)] struct Opts { /// URL to the Ethereum RPC provider - #[clap(short, long)] + #[clap(short, long, default_value = DEFAULT_RPC_URL)] rpc: Option, /// Path to the input CSV file r#in: PathBuf, /// Path to write the output checkpoint JSON file to + #[clap(default_value = DEFAULT_OUTPUT_PATH)] out: Option, }