Meteora DLMM SDK

repository·main·Indexed 43 days ago

https://github.com/meteoraag/dlmm-sdk

SDK and CLI tools for interacting with Meteora's Dynamic Liquidity Market Maker (DLMM) concentrated liquidity market maker. Provides implementations in TypeScript, Python, and Rust for liquidity management, market making, and performing swaps. Includes a comprehensive CLI for liquidity management, trading, limit orders, and protocol administration.

Tokens
68.6K
Snippets
270
Records
329
Agent score
55%

What's inside DLMM SDK

  1. Setup and Run DLMM SDK (Development)

    main

    If you are contributing to or developing the SDK locally, follow these steps to set up the environment:

    1. Install poetry.
    2. Navigate to python-client/dlmm and run poetry install to install dependencies.
    3. In a separate terminal, navigate to ts-client, run npm install, and then npm start-server to start the local server.
    4. Ensure API_URL in dlmm.py is set to localhost:3000 if you are using the local server.
    5. To add new dependencies, use poetry add package_name.
    6. To run tests located in the dlmm/tests directory, use poetry run pytest.
    # Install python dependencies
    cd python-client/dlmm
    poetry install
    
    # Setup TS server
    cd ts-client
    npm install
    npm start-server
    
    # Run tests
    poetry run pytest
  2. Test the TypeScript SDK

    main

    To run tests for the TypeScript SDK (ts-client), follow these steps to set up a local network and execute the test suite:

    1. Navigate to the client directory: cd ts-client
    2. Start a local Anchor network with localnet features: anchor localnet -- --features localnet
    3. Execute the tests using pnpm: pnpm run test
    cd ts-client
    anchor localnet -- --features localnet
    pnpm run test
  3. DLMM CLI Toolchain Requirements

    main

    The DLMM CLI requires specific Rust toolchain configurations depending on your hardware architecture.

    For standard environments, use channel 1.76.0.

    If you are using an Apple M1 chip, you may need to specify the target triple as x86_64-apple-darwin (e.g., 1.76.0-x86_64-apple-darwin).

  4. Understand LimitOrderStatus values

    main

    The LimitOrderStatus enum represents the current state of a specific bin within a limit order:

    • NotFilled: The order has not been matched against any swaps.
    • PartialFilled: Part of the order has been matched, but some amount remains unfilled.
    • Fulfilled: The entire order amount for that bin has been matched/processed.
  5. Manage Liquidity Positions

    main

    The SDK uses several interfaces to describe liquidity positions and their data.

    Position Data Structures

    • LbPosition: A high-level representation of a position containing its publicKey, positionData, and version (PositionVersion).
    • PositionInfo: A comprehensive view of a user's position, including the lbPair, tokenX and tokenY reserves, and an array of lbPairPositionsData.
    • PositionData: Detailed state of a position, including total amounts, bin data, fees, rewards, and owner information.
    • PositionBinData: Granular data for a specific bin within a position, including prices, amounts, and liquidity.

    Position Versions

    PositionVersion is an enum with values:

    • V1
    • V2