Evan-Kim2028 / cfmms-rs

CFMM lib built in Rust enabling pair syncing and swap simulation with pools on Ethereum.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

------------------------------------

Tests and Docs are still being written πŸ—οΈ.

Tests are still being written, assume bugs until tested. If you would like to help contribute on the tests or docs, feel free to open up an issue or make a PR.

------------------------------------

cfmms-rs

cfmms-rs is a vertically integrated library for interacting with CFMMs (constant function market makers) on Ethereum. Features include:

  • batch sync token pair data from Uniswap V2 and V3 through optimized smart contracts that minimize the number of RPC calls

  • calculate token pair spot prices and simulate token swaps

  • execute transactions Sync pairs simulate swaps, and interact with constant function market makers on Ethereum.

  • Crates.io

  • Documentation in progress

Project Layout

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ batch_requests/
        |── uniswap_v2/
        |── uniswap_v3/
β”‚   β”œβ”€β”€ dex/
        |── mod.rs
        |── uniswap_v2.rs
        |── uniswap_v3.rs
β”‚   β”œβ”€β”€ pool/
        |── mod.rs
        |── uniswap_v2.rs
        |── uniswap_v3.rs
β”‚   β”œβ”€β”€ abi.rs
β”‚   β”œβ”€β”€ checkpoint.rs
β”‚   β”œβ”€β”€ errors.rs
β”‚   β”œβ”€β”€ lib.rs
β”‚   β”œβ”€β”€ sync.rs
β”‚   └── throttle.rs
β”œβ”€β”€ Cargo.lock
β”œβ”€β”€ Cargo.toml
β”œβ”€β”€ foundry.toml
└── README.md

The core logic is contained in the following files:

  • batch_requests - handles batch pool requests to the Ethereum endpoint using solidity contracts in contracts/
  • dex - contains interfaces that handle dex invariants
  • pool - contains pool interfaces that handle pools based on dex invariants
  • abi - generates bindings for the UniswapV2 and UniswapV3 contracts
  • sync - syncs multiple pool states between all dexes

Supported Dexes

Dex Status
UniswapV2 variants βœ…
UniswapV3 βœ…

Build, Run Tests, and Examples

  1. In order to build, clone the github repo: git clone https://github.com/paradigmxyz/artemis cd artemis

  2. Run tests with cargo cargo test --all

  3. To run any of the examples, first set a local environment variable called ETHEREUM_MAINNET_ENDPOINT. Then you can simply run cargo run --example <example_name>.

About

CFMM lib built in Rust enabling pair syncing and swap simulation with pools on Ethereum.


Languages

Language:Rust 77.8%Language:Solidity 22.2%