Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <jack@jmcph4.dev>"]
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 = [
Expand Down Expand Up @@ -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"

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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] <IN> [OUT]

Arguments:
<IN> Path to the input CSV file
[OUT] Path to write the output checkpoint JSON file to [default: .cfmms-checkpoint.json]

Options:
-r, --rpc <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
}
}
]
}
```

6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Url>,
/// 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<PathBuf>,
}

Expand Down