From f52554ce8495115cab3007818d5bdc5872645811 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Wed, 20 Sep 2023 15:46:41 +0300 Subject: [PATCH] chore: draft update for readme --- CHANGELOG.md | 7 +++++++ README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6c582..fe95cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## v5.0.5 + +### Feat: + + - Add support to stake into Marinade Native with or without Referral Code + - Add support to unstake from Marinade Native + ## v5.0.4 ### Fix: diff --git a/README.md b/README.md index 2c43f10..c464ffe 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,49 @@ const { const signature = await provider.send(transaction) ``` +### Marinade Native Staking + +Now you can stake into Marinade Native via the SDK with or without referral code. + +#### Stake without referral code +In case of no referral code, the methods exposed in `marinade-native-stake.ts` are just a wrapper of what is already documented in the [Native Stake SDK](https://www.npmjs.com/package/@marinade.finance/native-staking-sdk). +Note that without referral code you're getting only Transaction Instructions. + +#### Stake with referral code +In order to get a referral code you must go to the [Marinade dApp](https://marinade.finance/app/earn/) to retrieve it. +Note that with referral code you're getting Versioned Transaction. +After having the code you can pass it to the methods mentioned below. + +Stake SOL to Marinade Native +```ts +... +const versionedTransaction = await getRefNativeStakeSOLTx(userPublicKey, amountLamports, refCode) +// sign and send the `transaction` +const signature = await wallet.sendTransaction(unsignedTx, connection) +``` + +Deposit Stake Account to Marinade Native +```ts +... +const versionedTransaction = await getRefNativeStakeAccountTx(userPublicKey, stakeAccountAddress, refCode) +// sign and send the `transaction` +const signature = await wallet.sendTransaction(versionedTransaction, connection) +``` + +#### Prepare for Unstake from Marinade Native +In order to merge stake accounts back into one and start the unstake process you must run the command from below and pay the fee (SOL needed to merge the accounts back). + +```ts +... +const transaction = new Transaction() +const prepareUnstakeIx = await getPrepareNativeUnstakeSOLIx(userPublicKey, amountLamports) +transaction.add(...prepareUnstakeIx.payFees) +// sign and send the `transaction` +const signature = await wallet.sendTransaction(transaction, connection) +await authIx.onPaid() +``` + + ### Liquidity pool Add liquidity to the liquidity pool and receive LP tokens: diff --git a/package.json b/package.json index 2d1dc35..5d290af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@marinade.finance/marinade-ts-sdk", - "version": "5.0.4", + "version": "5.0.5", "description": "Marinade SDK for Typescript", "main": "dist/src/index.js", "repository": {