npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dloom-flow/dlmm-sdk

v2.1.0

Published

A powerful and user-friendly SDK for the DLMM program on Solana.

Downloads

70

Readme

DLMM DApp - TypeScript SDK

🧩 Introduction

Welcome to the official TypeScript SDK for the DLMM (Dynamic Liquidity Market Maker) DApp.
This SDK provides developers with the tools to easily interact with the on-chain DLMM program on Solana.

Whether you are building a trading interface, a liquidity management tool, or any other application that integrates with DLMM, this SDK simplifies the process.

The DLMM is an innovative automated market maker that divides liquidity into discrete price bins, allowing for concentrated liquidity and reduced slippage for traders.
This SDK offers both high-level, user-friendly methods for common operations and low-level instruction builders for advanced use cases.


✨ Features

  • High-Level Abstractions – Simplified methods for common operations like adding liquidity, rebalancing, and initializing bins.
  • Low-Level Instruction Builders – Granular control to compose custom transactions for advanced use cases.
  • Account Fetching – Easily fetch and deserialize on-chain Pool and Position data.
  • TypeScript Support – Strong typing for safer and faster development.

⚙️ Installation

You can install the SDK using npm or yarn:

# Using npm
npm install @your-package-name/dlmm-sdk @solana/web3.js @coral-xyz/anchor

# Or using yarn
yarn add @your-package-name/dlmm-sdk @solana/web3.js @coral-xyz/anchor
🚀 Getting Started
Initialization
To start interacting with the DLMM program, you need to initialize the DlmmService.
This requires a Solana Connection and a Wallet object that conforms to the required interface.

typescript
Copy code
import { Connection, Keypair } from "@solana/web3.js";
import { DlmmService } from "@your-package-name/dlmm-sdk";

// Initialize connection to the Solana cluster
const connection = new Connection("https://api.devnet.solana.com", "confirmed");

// Example wallet object implementing the SDK's Wallet interface
const wallet = {
  publicKey: payer.publicKey,
  signTransaction: (tx) => tx.sign(payer),
  signAllTransactions: (txs) => txs.map(tx => tx.sign(payer)),
};

// Create a new instance of the DlmmService
const dlmmService = new DlmmService(connection, wallet);
📊 Fetching On-Chain Data
Get a Pool
typescript
Copy code
import { PublicKey } from "@solana/web3.js";

const poolAddress = new PublicKey("...");
const poolState = await dlmmService.getPool(poolAddress);

if (poolState) {
  console.log("Pool State:", poolState);
}
Get a Position
typescript
Copy code
import { PublicKey } from "@solana/web3.js";

const positionAddress = new PublicKey("...");
const positionState = await dlmmService.getPosition(positionAddress);

if (positionState) {
  console.log("Position State:", positionState);
}
🧠 Usage Examples
Initialize Bins for a Pool
Before adding liquidity to a certain price range, the corresponding bins may need to be initialized.

typescript
Copy code
const initializeBinsTxs = await dlmmService.initializeBinsInRange({
  pool: poolAddress,
  fromBinId: 100,
  toBinId: 120,
});

// Sign and send each transaction
for (const tx of initializeBinsTxs) {
  const signature = await wallet.signTransaction(tx).then(signedTx =>
    connection.sendRawTransaction(signedTx.serialize())
  );
  await connection.confirmTransaction(signature);
}
Add Liquidity
This example demonstrates how to add liquidity to a specified range of bins in a pool.

typescript
Copy code
import { BN } from "@coral-xyz/anchor";

const { transaction, positionMint } = await dlmmService.addLiquidity({
  pool: poolAddress,
  lowerBinId: 100,
  upperBinId: 120,
  amountToDeposit: new BN(1_000_000), // Amount in smallest token unit
  binAccountPubkeys: [/* Array of bin public keys */],
});

// The new position's mint Keypair must also sign the transaction
transaction.partialSign(positionMint);

const signedTx = await wallet.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTx.serialize());
await connection.confirmTransaction(signature);

console.log("Liquidity added. New position NFT mint:", positionMint.publicKey.toBase58());
Rebalance Liquidity
Move liquidity from an old position to a new one.
This is done in two transactions to avoid exceeding Solana transaction size limits.

typescript
Copy code
const {
  removeLiquidityTransaction,
  addLiquidityTransaction,
  newPositionMint,
} = await dlmmService.rebalanceLiquidity({
  oldPosition: oldPositionAddress,
  newLowerBinId: 110,
  newUpperBinId: 130,
  newPositionBinPubkeys: [/* Array of new bin public keys */],
});

// --- Transaction 1: Remove Liquidity ---
const signedRemoveTx = await wallet.signTransaction(removeLiquidityTransaction);
const removeSig = await connection.sendRawTransaction(signedRemoveTx.serialize());
await connection.confirmTransaction(removeSig);

console.log("Liquidity removed from old position.");

// --- Transaction 2: Add Liquidity ---
addLiquidityTransaction.partialSign(newPositionMint); // New position mint must sign
const signedAddTx = await wallet.signTransaction(addLiquidityTransaction);
const addSig = await connection.sendRawTransaction(signedAddTx.serialize());
await connection.confirmTransaction(addSig);

console.log("Liquidity added to new position.");
📘 API Reference
DlmmService Class
Main service class for interacting with the DLMM program.

Constructor
typescript
Copy code
new DlmmService(connection, wallet, programId?)
High-Level Methods
addLiquidity(params) – Prepares a transaction to add liquidity.

rebalanceLiquidity(params) – Creates transactions to remove and re-add liquidity.

initializeBinsInRange(params) – Prepares transactions to initialize bin accounts.

Low-Level Instruction Builders
These methods return TransactionInstruction objects for custom transactions:

createInitializePoolInstruction(params)

createAddLiquidityInstruction(params)

createSwapInstruction(params)

createRemoveLiquidityInstruction(params)

createBurnEmptyPositionInstruction(params)

createInitializeBinInstruction(params)

For detailed parameters, refer to the source code in core.ts.

🤝 Contributing
Contributions to the SDK are welcome!
Please feel free to open an issue or submit a pull request.

📄 License
This SDK is licensed under the MIT License.