Joe V2 Liquidity Book

repository·main·Indexed 41 days ago

https://github.com/lfj-gg/joe-v2

A Liquidity Book implementation featuring advanced liquidity management, swap routing, and pair deployment. Core components include LBPair for swap logic, LBToken for share calculation, LBFactory for pair registry and deployment, LBRouter as the primary user entry point, and LBQuoter for route optimization.

Tokens
806
Snippets
5
Records
6
Agent score
1%

What's inside Joe V2

  1. Overview of Joe V2: Liquidity Book components

    main

    Joe V2 consists of several core smart contracts that manage liquidity, swaps, and routing. Understanding the role of each contract is essential for correct interaction:

    • LBPair: Contains the core logic for swaps, liquidity additions/removals, and fee claiming. Warning: Do not deploy this contract directly; always use the LBFactory.
    • LBToken: A token standard used to calculate user shares. It is similar to ERC-1155 but lacks callbacks and ERC-721-related functionality for enhanced safety.
    • LBFactory: The registry for all pairs and the mechanism for deploying them. It also manages privileged parameters like fee settings, flashloan fees, pair implementations, quoter settings, and presets. Pair creation is restricted to the owner unless creationUnlocked is set to true.
    • LBRouter: The primary entry point for users. It provides additional security checks and should be used instead of interacting with pairs directly.
    • LBQuoter: A utility contract used to determine the best route among several options. It should be consulted before performing a swap to ensure optimal returns.
  2. Install Foundry on Linux and macOS

    main

    To install Foundry on Linux or macOS, use the foundryup installer.

    1. Download and run the installer script via curl.
    2. Run foundryup to complete the installation.

    To update Foundry to the latest version, run foundryup again. To revert to a specific version, use the -v flag.

    curl -L https://foundry.paradigm.xyz | bash
    foundryup
  3. Install Foundry on Windows

    main

    Foundry must be built from source on Windows:

    1. Download and run rustup-init from rustup.rs.
    2. Use cargo to install the Foundry CLI and Anvil from the GitHub repository.
    # After installing rustup
    cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil --bins --locked
  4. Configure Slither analysis settings

    main

    The slither.config.json file is used to configure the Slither static analysis tool for this repository. It defines which paths to include/exclude during analysis and how to resolve Solidity imports via remappings.

    Key configuration keys:

    • filter_paths: A regex string used to filter the paths analyzed by Slither. In this project, it is set to include lib/, test/, and script/ directories.
    • solc_remaps: An array of strings mapping Solidity import paths to their actual filesystem locations. This ensures Slither can correctly resolve dependencies like OpenZeppelin or Forge-std.
    {
      "filter_paths": "(lib/|test/|script/)",
      "solc_remaps": [
        "ds-test/=lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin/=lib/openzeppelin-contracts/contracts/"
      ]
    }