Skip to content

Marinade Ts/Js SDK

This is a marinade typescript and anchor based SDK to interact with Marinade from any Front-End App

Which SDK Do I Need

ProductPackageRepository
mSOL liquid staking, Instant Unstake, legacy mSOL/SOL liquidity pool (inactive)@marinade.finance/marinade-ts-sdkmarinade-ts-sdk
Marinade Native@marinade.finance/native-staking-sdknative-staking
Marinade Select, existing positions only@marinade.finance/native-staking-sdknative-staking
Validator bonds, SAM bidding, PSR@marinade.finance/validator-bonds-clivalidator-bonds

Marinade Select is not currently available to stake to. The SDK still covers Select for integrations serving existing positions, but do not build a new Select staking flow against it. Build against Marinade Native instead, or talk to the team.


Install

npm install @marinade.finance/marinade-ts-sdk
yarn add @marinade.finance/marinade-ts-sdk

Check the package page for the current version rather than pinning one from this doc.


Quickstart

import { Marinade, MarinadeConfig } from '@marinade.finance/marinade-ts-sdk'
import { Connection } from '@solana/web3.js'

const config = new MarinadeConfig({
  connection: new Connection('https://api.mainnet-beta.solana.com'),
  publicKey: wallet.publicKey,
})
const marinade = new Marinade(config)

// Stake SOL, receive mSOL
const { transaction } = await marinade.deposit(amountLamports)

The SDK also exposes liquidUnstake, orderUnstake, addLiquidity and removeLiquidity, plus protocol state through marinade.getMarinadeState().

For the same operations from a terminal, use marinade-ts-cli.


Integration Example

An Anchor CPI integration example is available:

That example wraps deposits through the referral program, which is currently paused. No referral fees accrue to anyone while it is paused, including under agreements signed before the pause, and the partner boost is not in force. Use the repository as a reference for calling Marinade by CPI, but do not build a revenue-sharing integration on it without talking to the team first. For a plain integration, call the SDK directly as shown above.


If you have questions or troubles, please join our Discord. Marinade contributors will be there to help you.