Gasless Liquid Staking with Marinade
Stake SOL for mSOL with zero gas fees via LazorKit
Devnet Notice
This demo runs on Solana Devnet. Liquidity pool depth may vary, affecting unstake fees.
๐ค Marinade x LazorKit
Liquid staking with LazorKit smart wallet integration.
What is mSOL?
mSOL is Marinade's liquid staking token. When you stake SOL with Marinade, you receive mSOL in return.
Unlike regular staking, mSOL is liquid โ you can trade it, use it in DeFi, or unstake at any time.
The mSOL/SOL exchange rate increases over time as staking rewards accrue.
๐ฐ Token Account Rent
On your first stake, Solana creates an mSOL token account which requires a one-time rent deposit of ~0.002 SOL.
This rent is fully reclaimable if you close the account later. The LazorKit paymaster covers gas fees, but rent is paid from your SOL balance.
Making Marinade Work with LazorKit
Initialize Marinade and build the stake/unstake transaction:
const config = new MarinadeConfig({
connection,
publicKey: new PublicKey(wallet.smartWallet),
});
const marinade = new Marinade(config);
// Build stake transaction
const { transaction } = await marinade.deposit(
new BN(amount * LAMPORTS_PER_SOL)
);LazorKit manages compute budget automatically. Remove any ComputeBudget instructions from the SDK:
const COMPUTE_BUDGET_PROGRAM = new PublicKey( 'ComputeBudget111111111111111111111111111111' ); const instructions = transaction.instructions.filter( ix => !ix.programId.equals(COMPUTE_BUDGET_PROGRAM) );
LazorKit's execute_cpi validates that the smart wallet is present in ALL instruction account lists:
instructions.forEach((ix) => {
const hasSmartWallet = ix.keys.some(
k => k.pubkey.toBase58() === wallet.smartWallet
);
if (!hasSmartWallet) {
ix.keys.push({
pubkey: new PublicKey(wallet.smartWallet),
isSigner: false,
isWritable: false
});
}
});await signAndSendTransaction({
instructions,
transactionOptions: { computeUnitLimit: 400_000 }
});๐ก This pattern applies to most Solana protocols when integrating with LazorKit
What You'll Learn
- โIntegrate Marinade SDK with LazorKit
- โProcess external SDK transactions for LazorKit
- โFetch real-time quotes from Marinade state
- โDisplay liquid staking token (mSOL) balances
Connect Your Wallet
Use LazorKit smart wallet for gasless staking