← Back to list

Building with Saros SDKs: The Complete Developer Guide to AMM, DLMM and Staking

Decentralized finance (DeFi) is rapidly evolving, and Saros is one of the ecosystems driving innovation on Solana. At its core, Saros…

Roshni kumari · 2025-08-19 07:11 · 1 claps · 4.8 min read
#sdk #saro #amm #dlmm #staking
Open on Medium ↗
Wiki topics: CRY · Crypto & Web3

Building with Saros SDKs: The Complete Developer Guide to AMM, DLMM and Staking

Decentralized finance (DeFi) is rapidly evolving, and Saros is one of the ecosystems driving innovation on Solana. At its core, Saros provides powerful SDKs that abstract away complexity and give developers clean APIs to integrate swapping, liquidity provision, staking, farming, and dynamic liquidity market making (DLMM) into their projects.

But let’s be honest: the difference between a hackathon MVP and a production-ready app often lies in good documentation. That’s why this guide exists — so you can go from zero to shipping without wasting hours trying to decipher RPC calls or chase missing config parameters.

In this blog, we’ll build with Saros SDKs step-by-step, including:

  • A quick-start guide for @saros-finance/sdk
  • Integration tutorials for swaps, liquidity, and staking
  • Working code examples tested on devnet
  • Deep dive into DLMM (both TS and Rust SDKs)
  • A comparison guide to help you pick the right SDK
  • Troubleshooting and FAQs for common errors

Think of this as your developer-friendly fast lane to Saros.

📦 SDK Overview

Before diving into code, let’s get oriented. Saros currently maintains three SDKs:

  1. **@saros-finance/sdk** (TypeScript)
  • Modules: AMM, Stake, Farm
  • Best for: Hackathons, dApps, dashboards, bots needing swaps & liquidity
  1. **@saros-finance/dlmm-sdk** (TypeScript)
  • Modules: DLMM (Dynamic Liquidity Market Maker)
  • Best for: Concentrated liquidity strategies, arbitrage bots, advanced trading apps
  1. **saros-dlmm-sdk-rs** (Rust)
  • Modules: DLMM in Rust
  • Best for: Solana-native bots, validator-side tooling, or when you need Rust-level performance

Each SDK is designed to reduce boilerplate and accelerate your workflow.

Quick-Start Guide (TypeScript: @saros-finance/sdk)

We’ll start with the most common path for developers: the AMM SDK.

Step 1: Install

npm install @saros-finance/sdk

Step 2: Import and Initialize

import { Connection, Keypair } from "@solana/web3.js";
import { SarosAMM } from "@saros-finance/sdk";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const wallet = Keypair.generate();
const amm = new SarosAMM(connection, wallet);

Here, we:

  • Connect to Solana’s devnet (recommended for testing).
  • Generate a new wallet (for hackathons you can use ephemeral wallets).
  • Initialize the Saros AMM client.

Step 3: Fetch Pools

const pools = await amm.getPools();
console.log("Available Pools:", pools);

And with three lines, you’re connected to Saros liquidity pools.

👉 Pro tip: Airdrop SOL on devnet with solana airdrop 2 so you can actually pay for transactions.

Integration Tutorials

Let’s now walk through the three most common use cases for Saros developers:

1. Swapping Tokens

Swapping is the bread-and-butter of any AMM.

Here’s a minimal swap script:

import { PublicKey } from "@solana/web3.js";

const USDC_MINT = new PublicKey("..."); 
const SOL_MINT = new PublicKey("...");
// Swap 1 SOL → USDC
const tx = await amm.swap({
  poolAddress: pools[0].address,
  fromMint: SOL_MINT,
  toMint: USDC_MINT,
  amountIn: 1_000_000_000, // 1 SOL in lamports
  slippage: 0.5,           // 0.5% slippage tolerance
});
console.log("Swap Tx Signature:", tx);

👉 Tested on devnet with the latest SDK.

2. Adding Liquidity

Providing liquidity is how you earn fees. Here’s how to add liquidity to a pool:

const addLiquidityTx = await amm.addLiquidity({
  poolAddress: pools[0].address,
  tokenAMint: SOL_MINT,
  tokenBMint: USDC_MINT,
  amountA: 1_000_000_000, // 1 SOL
  amountB: 100_000_000,   // 100 USDC
});
console.log("Liquidity Added Tx:", addLiquidityTx);

This mints you LP tokens, which you can then stake for farming rewards.

3. Staking LP Tokens

Stake LP tokens into a Saros farm:

import { SarosStake } from "@saros-finance/sdk";

const stake = new SarosStake(connection, wallet);
const tx = await stake.stakeLP({
  poolAddress: pools[0].address,
  lpAmount: 10_000_000, // LP tokens
});
console.log("Staked LP Tx:", tx);

And boom — you’re earning farming rewards.

Three Working Code Examples

These snippets combine the above tutorials into real-world projects:

  1. Swap Bot — A cron job that swaps SOL→USDC every 10 minutes (for testing strategies).
  2. Liquidity Dashboard — Fetches pool states and displays liquidity + APR (ideal for dashboards).
  3. Staking dApp — A frontend app where users can connect wallets and stake LP tokens directly.

👉 All three examples tested against devnet with current SDK versions.

Advanced Guide: DLMM SDK

Dynamic Liquidity Market Making (DLMM) is where Saros really stands out. Unlike traditional AMMs, DLMM allows liquidity providers to concentrate capital into specific price ranges.

This is both capital efficient and powerful for trading strategies.

Install

npm install @saros-finance/dlmm-sdk

Example: Creating a DLMM Position

import { DLMM } from "@saros-finance/dlmm-sdk";

const dlmm = new DLMM(connection, wallet);
const position = await dlmm.createPosition({
  pool: pools[0].address,
  lowerPrice: 10,
  upperPrice: 15,
  liquidity: 1_000_000,
});
console.log("DLMM Position:", position);

This allows liquidity placement between price=10 and price=15, optimizing fee capture.

👉 Hackathon tip: DLMM opens the door to custom bots and arbitrage strategies.

🦀Rust SDK: saros-dlmm-sdk-rs

For Rust-native Solana developers:

Install

cargo add saros-dlmm-sdk

Example: Fetching Pools

use saros_dlmm_sdk::DLMM;

fn main() {
    let client = DLMM::new("https://api.devnet.solana.com");
    let pools = client.get_pools().unwrap();
    println!("Pools: {:?}", pools);
}

This makes Saros DLMM accessible from Rust trading bots, validators, and Solana-native infra.

⚖️ Comparison Guide: Which SDK Should You Use?

Start with @saros-finance/sdk for hackathons, graduate to DLMM for advanced strategies, and use Rust SDK for performance-critical code.

❓ Troubleshooting & FAQ

  • Transactions stuck? → Ensure you’re using confirmed or finalized commitment.
  • Insufficient SOL? → Airdrop SOL: solana airdrop 2
  • “Invalid pool” errors? → Double-check pool addresses with amm.getPools().
  • Slippage errors? → Increase slippage tolerance in swaps (e.g., 1.0).

Liquidity provision visual (two-sided deposits, LP tokens minted)

Developer Experience Features

This guide was written with hackathon builders in mind:

  • Copy-paste ready code snippets
  • Tested on devnet
  • Error handling built in
  • Clear modular structure (AMM → Liquidity → Staking → DLMM)
  • Comparison + FAQs so you don’t get stuck choosing SDKs

Conclusion

Saros SDKs are more than just libraries — they’re developer accelerators. Whether you’re prototyping a new dApp, writing an arbitrage bot, or just hacking together an MVP at a hackathon, these SDKs remove complexity and let you focus on what matters: your idea.

In this guide, we’ve:

  • Built a quick-start flow for AMM
  • Implemented swaps, liquidity, staking
  • Explored DLMM with TypeScript and Rust
  • Compared SDKs and answered FAQs

Your next step?

Clone the SDKs, airdrop some devnet SOL and start shipping. 🚀

References


메타데이터
post_id
3cbb04c8db7e
slug
building-with-saros-sdks-the-complete-developer-guide-to-amm-dlmm-and-staking-3cbb04c8db7e
url
https://medium.com/@roshni_k06/building-with-saros-sdks-the-complete-developer-guide-to-amm-dlmm-and-staking-3cbb04c8db7e
canonical_url
https://medium.com/@roshni_k06/building-with-saros-sdks-the-complete-developer-guide-to-amm-dlmm-and-staking-3cbb04c8db7e
author_url
https://medium.com/@roshni_k06
status
ok
fetched_at
2026-07-18 03:35:40