Comment on page
mSOL is the liquid staking token representing stake position in the Marinade stake pool. The supply of this token is controlled by Marinade using burning and minting operations in accordance with the overall state of the program.
This token constantly increases in price after each epoch, as long as there are staking rewards distributed. The rewards are accumulated on
Price of mSOL =
total_staked / tokens_minted
mSOL token address: mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So
This situation is often quickly fixed by arbitrage. Nonetheless, we invite our users to compare the price of mSOL on Marinade to the one on DEXs in your trades and choose the most profitable for you.
Marinade is using a 30-day simple moving average of the 14-day APY to display its final APY.
This means that every day, Marinade looks at the mSOL price and compares it to the price mSOL had 14 days before. A 30-day average of those measurements is then used to display a final APY, projected over a year.
- After reading Marinade state, you'll have
marinade_state.msol_price: u64, and that's mSOL price in SOL multiplied by 0x1_0000_0000 (shifted), so to obtain mSOL/SOL as f64 you should do:
let msol_price_f64: f64 = marinade_state.msol_price as f64 / 0x1_0000_0000 as f64, and then you get the true mSOL/SOL price.
You start with the previous example and some amount of mSOL-lamports, then:
let SOL_lamports = (mSOL_lamports as u128 * marinade_state.msol_price as u128 / 0x1_0000_0000 as u128) as u64
mSOL uses 9 decimals, as SOL.
let mSOL_lamports = (mSOL_lamports as u128 * 0x1_0000_0000 as u128 / marinade_state.msol_price as u128) as u64
If you have access to SOL/USDC price from an oracle, the best way to avoid losses due to price inaccuracies is to derive mSOL/USDC from SOL/USDC and Marinade true price
let mSOL_usdc = (SOL_usdc as u128 * marinade_state.msol_price as u128 / 0x1_0000_0000 as u128) as u64
msol_price is computed and stored at this link (https://github.com/marinade-finance/liquid-staking-program/blob/main/programs/marinade-finance/src/state/update.rs#L247) after each epoch ends, when SOL staking rewards are added to the pool.
You can also use the fns
marinade_state.calc_msol_from_lamports()for better precision when computing mSOL from SOL and vice versa.