This project implements a Marinade-compatible Liquid Staking smart contract on Solana with a full suite of Web3-based test cases.
- Stake SOL and receive mSOL (Marinade Staked SOL)
- Unstake to receive SOL back
- mSOL/SOL accounting via Marinade protocol
- Web3-based test suite with
@solana/web3.js
and@project-serum/anchor
- Simulates staking/unstaking in a local test validator
.
├── programs/
│ └── marinade_staking/ # Solana smart contract (Anchor)
├── tests/
│ └── marinade.test.ts # Web3 test cases
├── migrations/
├── Anchor.toml
├── Cargo.toml
└── README.md
- Anchor
- Solana CLI
- Node.js >= 16
- Yarn or NPM
git clone https://github.com/your-username/marinade-liquid-staking.git
cd marinade-liquid-staking
yarn install
anchor build
anchor deploy
anchor test
it("Stake SOL and receive mSOL", async () => {
const tx = await program.methods
.stake(new anchor.BN(1_000_000_000)) // 1 SOL
.accounts({
user: user.publicKey,
marinadeState: marinadeStatePDA,
msolMint: msolMint,
systemProgram: SystemProgram.programId,
})
.signers([user])
.rpc();
const msolBalance = await getTokenBalance(userMsolATA);
assert.ok(msolBalance > 0, "User should receive mSOL");
});
- Written in Rust using Anchor
- Interacts with Marinade's on-chain staking pool
- Performs CPI calls to stake/unstake
MIT License
Built on top of the Marinade Finance staking protocol.