From ab79ee1fa3e69ab3f926bc258044c1d1e1c9942c Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Wed, 20 Sep 2023 15:22:11 +0300 Subject: [PATCH 1/6] feat: add support for using Marinade Native in the SDK --- package.json | 11 +-- pnpm-lock.yaml | 31 +++++++- src/marinade-native-stake.ts | 121 +++++++++++++++++++++++++++++ src/marinade-native-stake.types.ts | 11 +++ tsconfig.json | 2 +- 5 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 src/marinade-native-stake.ts create mode 100644 src/marinade-native-stake.types.ts diff --git a/package.json b/package.json index df7cfcd..2d1dc35 100644 --- a/package.json +++ b/package.json @@ -37,24 +37,28 @@ "dependencies": { "@coral-xyz/anchor": "^0.28.0", "@marinade.finance/directed-stake-sdk": "^0.0.4", + "@marinade.finance/native-staking-sdk": "^1.0.0", "@solana/spl-stake-pool": "^0.6.5", "@solana/spl-token-3.x": "npm:@solana/spl-token@^0.3.8", "borsh": "^0.7.0", "bs58": "^5.0.0" }, "devDependencies": { + "@jest/globals": "^29.5.0", + "@solana/web3.js": "^1.74.0", "@types/bn.js": "^5.1.1", "@types/bs58": "^4.0.1", "@types/jest": "^29.5.1", - "@jest/globals": "^29.5.0", "@types/node": "^18.16.3", "@typescript-eslint/eslint-plugin": "^5.59.1", "@typescript-eslint/parser": "^5.59.1", + "bn.js": "^5.2.1", "eslint": "^8.39.0", "gts": "^3.1.1", "husky": "^8.0.3", "jest": "^29.5.0", "jest-each": "^29.5.0", + "jsbi": "^4.3.0", "lint-staged": "^13.2.2", "node-polyfill-webpack-plugin": "^2.0.1", "terser-webpack-plugin": "^5.3.7", @@ -63,10 +67,7 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4", "webpack": "^5.81.0", - "webpack-cli": "^5.0.2", - "@solana/web3.js": "^1.74.0", - "bn.js": "^5.2.1", - "jsbi": "^4.3.0" + "webpack-cli": "^5.0.2" }, "engines": { "node": ">=16.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6441fbc..c11d1dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,9 @@ dependencies: '@marinade.finance/directed-stake-sdk': specifier: ^0.0.4 version: 0.0.4(@solana/web3.js@1.75.0)(bn.js@5.2.1)(jsbi@4.3.0) + '@marinade.finance/native-staking-sdk': + specifier: ^1.0.0 + version: 1.0.0 '@solana/spl-stake-pool': specifier: ^0.6.5 version: 0.6.5 @@ -77,7 +80,7 @@ devDependencies: version: 5.3.7(webpack@5.81.0) ts-jest: specifier: ^29.1.0 - version: 29.1.0(@babel/core@7.21.4)(jest@29.5.0)(typescript@5.0.4) + version: 29.1.0(jest@29.5.0)(typescript@5.0.4) ts-loader: specifier: ^9.4.2 version: 9.4.2(typescript@5.0.4)(webpack@5.81.0) @@ -917,6 +920,19 @@ packages: - utf-8-validate dev: false + /@marinade.finance/native-staking-sdk@1.0.0: + resolution: {integrity: sha512-Cj2dy3SH9LAgcFBpGEgRHyF/nK+L7SfNIHkGqAZYRDVgn/h7u8bqKNkYqKXgCWbA5WwPmJzugWWm1DxEt7LyPQ==} + dependencies: + '@solana/spl-memo': 0.2.3(@solana/web3.js@1.75.0) + '@solana/web3.js': 1.75.0 + bn.js: 5.2.1 + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - utf-8-validate + dev: false + /@noble/ed25519@1.7.3: resolution: {integrity: sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==} @@ -995,6 +1011,16 @@ packages: dependencies: buffer: 6.0.3 + /@solana/spl-memo@0.2.3(@solana/web3.js@1.75.0): + resolution: {integrity: sha512-CNsKSsl85ebuVoeGq1LDYi5M/PMs1Pxv2/UsyTgS6b30qrYqZOXha5ouZzgGKtJtZ3C3dxfOAEw6caJPN1N63w==} + engines: {node: '>=16'} + peerDependencies: + '@solana/web3.js': ^1.20.0 + dependencies: + '@solana/web3.js': 1.75.0 + buffer: 6.0.3 + dev: false + /@solana/spl-stake-pool@0.6.5: resolution: {integrity: sha512-gAYjX4LlRem3Bje1csZOOBStX8wAH8b8tu4sublUTIoJxLMdEbXqnwc8RJ2lAsmFkjxxomEM9Hk65F8jcvv15A==} dependencies: @@ -5296,7 +5322,7 @@ packages: engines: {node: '>=8'} dev: true - /ts-jest@29.1.0(@babel/core@7.21.4)(jest@29.5.0)(typescript@5.0.4): + /ts-jest@29.1.0(jest@29.5.0)(typescript@5.0.4): resolution: {integrity: sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -5317,7 +5343,6 @@ packages: esbuild: optional: true dependencies: - '@babel/core': 7.21.4 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 jest: 29.5.0(@types/node@18.16.3)(ts-node@10.9.1) diff --git a/src/marinade-native-stake.ts b/src/marinade-native-stake.ts new file mode 100644 index 0000000..5994165 --- /dev/null +++ b/src/marinade-native-stake.ts @@ -0,0 +1,121 @@ +import { + PublicKey, + TransactionInstruction, + VersionedTransaction, +} from '@solana/web3.js' +import BN from 'bn.js' +import { NativeStakingSDK } from '@marinade.finance/native-staking-sdk' +import { + AuthStakeSOLIxResponse, + UnstakeSOLIxResponse, +} from './marinade-native-stake.types' + +/** + * Fetches the instruction to stake SOL in Marinade Native + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {BN} amountToStake - The amount to deposit in lamports + * @returns {AuthStakeSOLIxResponse} - The instructions to add in transaction to stake in Marinade Native and new stake keypair + */ +export function getAuthNativeStakeSOLIx({ + userPublicKey, + amountToStake, +}: { + userPublicKey: PublicKey + amountToStake: BN +}): AuthStakeSOLIxResponse { + const nativeSdk = new NativeStakingSDK() + return nativeSdk.buildCreateAuthorizedStakeInstructions( + userPublicKey, + amountToStake + ) +} + +/** + * Fetches the transaction to stake SOL in Marinade Native with refCode + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {BN} amountToStake - The amount to deposit in lamports + * @param {string} mNativeRefCode - Marinade Native referral code + * @returns {Promise} - The transaction to stake SOL into Marinade native using Referral Code + */ +export async function getRefNativeStakeSOLTx({ + userPublicKey, + amountToStake, + mNativeRefCode, +}: { + userPublicKey: PublicKey + amountToStake: BN + mNativeRefCode: string +}): Promise { + const response = await fetch( + `https://native-staking-referral.marinade.finance/v1/tx/deposit-sol?amount=${amountToStake.toString()}&code=${mNativeRefCode}&user=${userPublicKey.toString()}` + ) + const serializedTx = await response.json() + + const txBuffer = Buffer.from(serializedTx, 'base64') + return VersionedTransaction.deserialize(txBuffer) +} + +/** + * Fetches the instruction to stake Stake Account in Marinade Native + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {PublicKey[]} stakeAccounts - The stake accounts that are about to be deposited in Marinade Native + * @returns {TransactionInstruction} - The instruction to add in transaction to stake in Marinade Native + */ +export function getAuthNativeStakeAccountIx({ + userPublicKey, + stakeAccounts, +}: { + userPublicKey: PublicKey + stakeAccounts: PublicKey[] +}): TransactionInstruction[] { + const nativeSdk = new NativeStakingSDK() + return nativeSdk.buildAuthorizeInstructions(userPublicKey, stakeAccounts) +} + +/** + * Fetches the transaction to deposit Stake Account in Marinade Native with refCode + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {PublicKey} stakeAccountAddress - The stake account to be deposited into Marinade Native + * @param {string} mNativeRefCode - Marinade Native referral code + * @returns {Promise} - The transaction to deposit Stake Account into Marinade native using Referral Code + */ +export async function getRefNativeStakeAccountTx({ + userPublicKey, + stakeAccountAddress, + mNativeRefCode, +}: { + userPublicKey: PublicKey + stakeAccountAddress: PublicKey + mNativeRefCode: string +}): Promise { + const response = await fetch( + `https://native-staking-referral.marinade.finance/v1/tx/deposit-stake-account?stake=${stakeAccountAddress.toString()}&code=${mNativeRefCode}&user=${userPublicKey.toString()}` + ) + + const serializedTx = await response.json() + + const txBuffer = Buffer.from(serializedTx, 'base64') + return VersionedTransaction.deserialize(txBuffer) +} + +/** + * Fetches the instruction to unstake from Marinade Native + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {BN} amountToUnstake - The amount to unstake in lamports + * @returns {UnstakeSOLIxResponse} - The instructions to pay the fee for unstake and the event that should be called after fee is paid in order to trigger unstake event faster (calling this is optional, but it ensures better experience for user). + */ +export async function getNativeUnstakeSOLIx({ + userPublicKey, + amountToUnstake, +}: { + userPublicKey: PublicKey + amountToUnstake: BN +}): Promise { + const nativeSdk = new NativeStakingSDK() + return await nativeSdk.initPrepareForRevoke(userPublicKey, amountToUnstake) +} diff --git a/src/marinade-native-stake.types.ts b/src/marinade-native-stake.types.ts new file mode 100644 index 0000000..f244566 --- /dev/null +++ b/src/marinade-native-stake.types.ts @@ -0,0 +1,11 @@ +import { Keypair, TransactionInstruction } from '@solana/web3.js' + +export type AuthStakeSOLIxResponse = { + createAuthorizedStake: TransactionInstruction[] + stakeKeypair: Keypair +} + +export type UnstakeSOLIxResponse = { + payFees: TransactionInstruction[] + onPaid: (signature: string) => Promise +} diff --git a/tsconfig.json b/tsconfig.json index 1a961ae..2368ecb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "lib": ["es2021"], + "lib": ["es2021", "dom"], "target": "ES6", "module": "CommonJS", "rootDir": ".", From f52554ce8495115cab3007818d5bdc5872645811 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Wed, 20 Sep 2023 15:46:41 +0300 Subject: [PATCH 2/6] 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": { From 1d40ed5acab77643e99d4d0f1cbcfe085a8e1ac2 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Wed, 20 Sep 2023 15:49:48 +0300 Subject: [PATCH 3/6] chore: expose the new methods --- README.md | 1 - src/index.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c464ffe..7cbaa67 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,6 @@ 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/src/index.ts b/src/index.ts index e8df7a9..933e04d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export { Marinade } from './marinade' +export * from './marinade-native-stake' export { MarinadeConfig } from './config/marinade-config' export * as MarinadeBorsh from './marinade-state/borsh/index' export { MarinadeReferralPartnerState } from './marinade-referral-state/marinade-referral-partner-state' From f9628403700144b6b9277df5456cb20e2b7878fd Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Wed, 20 Sep 2023 15:50:38 +0300 Subject: [PATCH 4/6] fix: better naming --- src/marinade-native-stake.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/marinade-native-stake.ts b/src/marinade-native-stake.ts index 5994165..d38d84c 100644 --- a/src/marinade-native-stake.ts +++ b/src/marinade-native-stake.ts @@ -109,7 +109,7 @@ export async function getRefNativeStakeAccountTx({ * @param {BN} amountToUnstake - The amount to unstake in lamports * @returns {UnstakeSOLIxResponse} - The instructions to pay the fee for unstake and the event that should be called after fee is paid in order to trigger unstake event faster (calling this is optional, but it ensures better experience for user). */ -export async function getNativeUnstakeSOLIx({ +export async function getPrepareNativeUnstakeSOLIx({ userPublicKey, amountToUnstake, }: { From aea333f0949303b33066b9f7bef9390c759b139a Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Thu, 21 Sep 2023 11:35:33 +0300 Subject: [PATCH 5/6] fix: simplify method signature and use the right prop from response --- src/marinade-native-stake.ts | 71 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/src/marinade-native-stake.ts b/src/marinade-native-stake.ts index d38d84c..634d680 100644 --- a/src/marinade-native-stake.ts +++ b/src/marinade-native-stake.ts @@ -17,13 +17,10 @@ import { * @param {BN} amountToStake - The amount to deposit in lamports * @returns {AuthStakeSOLIxResponse} - The instructions to add in transaction to stake in Marinade Native and new stake keypair */ -export function getAuthNativeStakeSOLIx({ - userPublicKey, - amountToStake, -}: { - userPublicKey: PublicKey +export function getAuthNativeStakeSOLIx( + userPublicKey: PublicKey, amountToStake: BN -}): AuthStakeSOLIxResponse { +): AuthStakeSOLIxResponse { const nativeSdk = new NativeStakingSDK() return nativeSdk.buildCreateAuthorizedStakeInstructions( userPublicKey, @@ -39,21 +36,17 @@ export function getAuthNativeStakeSOLIx({ * @param {string} mNativeRefCode - Marinade Native referral code * @returns {Promise} - The transaction to stake SOL into Marinade native using Referral Code */ -export async function getRefNativeStakeSOLTx({ - userPublicKey, - amountToStake, - mNativeRefCode, -}: { - userPublicKey: PublicKey - amountToStake: BN +export async function getRefNativeStakeSOLTx( + userPublicKey: PublicKey, + amountToStake: BN, mNativeRefCode: string -}): Promise { +): Promise { const response = await fetch( `https://native-staking-referral.marinade.finance/v1/tx/deposit-sol?amount=${amountToStake.toString()}&code=${mNativeRefCode}&user=${userPublicKey.toString()}` ) - const serializedTx = await response.json() + const result = await response.json() - const txBuffer = Buffer.from(serializedTx, 'base64') + const txBuffer = Buffer.from(result.serializedTx, 'base64') return VersionedTransaction.deserialize(txBuffer) } @@ -64,13 +57,10 @@ export async function getRefNativeStakeSOLTx({ * @param {PublicKey[]} stakeAccounts - The stake accounts that are about to be deposited in Marinade Native * @returns {TransactionInstruction} - The instruction to add in transaction to stake in Marinade Native */ -export function getAuthNativeStakeAccountIx({ - userPublicKey, - stakeAccounts, -}: { - userPublicKey: PublicKey +export function getAuthNativeStakeAccountIx( + userPublicKey: PublicKey, stakeAccounts: PublicKey[] -}): TransactionInstruction[] { +): TransactionInstruction[] { const nativeSdk = new NativeStakingSDK() return nativeSdk.buildAuthorizeInstructions(userPublicKey, stakeAccounts) } @@ -83,22 +73,18 @@ export function getAuthNativeStakeAccountIx({ * @param {string} mNativeRefCode - Marinade Native referral code * @returns {Promise} - The transaction to deposit Stake Account into Marinade native using Referral Code */ -export async function getRefNativeStakeAccountTx({ - userPublicKey, - stakeAccountAddress, - mNativeRefCode, -}: { - userPublicKey: PublicKey - stakeAccountAddress: PublicKey +export async function getRefNativeStakeAccountTx( + userPublicKey: PublicKey, + stakeAccountAddress: PublicKey, mNativeRefCode: string -}): Promise { +): Promise { const response = await fetch( `https://native-staking-referral.marinade.finance/v1/tx/deposit-stake-account?stake=${stakeAccountAddress.toString()}&code=${mNativeRefCode}&user=${userPublicKey.toString()}` ) - const serializedTx = await response.json() + const result = await response.json() - const txBuffer = Buffer.from(serializedTx, 'base64') + const txBuffer = Buffer.from(result.serializedTx, 'base64') return VersionedTransaction.deserialize(txBuffer) } @@ -109,13 +95,22 @@ export async function getRefNativeStakeAccountTx({ * @param {BN} amountToUnstake - The amount to unstake in lamports * @returns {UnstakeSOLIxResponse} - The instructions to pay the fee for unstake and the event that should be called after fee is paid in order to trigger unstake event faster (calling this is optional, but it ensures better experience for user). */ -export async function getPrepareNativeUnstakeSOLIx({ - userPublicKey, - amountToUnstake, -}: { - userPublicKey: PublicKey +export async function getPrepareNativeUnstakeSOLIx( + userPublicKey: PublicKey, amountToUnstake: BN -}): Promise { +): Promise { const nativeSdk = new NativeStakingSDK() return await nativeSdk.initPrepareForRevoke(userPublicKey, amountToUnstake) } + +/** + * Calls the bot to rebalance user's funds (relevant especially right after the users deposits in Marinade Native, but not mandatory) + * + * @param {PublicKey} userPublicKey - The PublicKey of the user + */ +export async function callRebalanceHint( + userPublicKey: PublicKey +): Promise { + const nativeSdk = new NativeStakingSDK() + return await nativeSdk.callRebalanceHint(userPublicKey) +} From df593a6e97a37a711ddff84730e02e60942390ca Mon Sep 17 00:00:00 2001 From: MjCage Date: Thu, 21 Sep 2023 12:35:10 +0200 Subject: [PATCH 6/6] fix: change comment and docs wording --- README.md | 13 +++++----- src/marinade-native-stake.ts | 48 ++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 7cbaa67..abf79ac 100644 --- a/README.md +++ b/README.md @@ -90,16 +90,15 @@ const signature = await provider.send(transaction) ### Marinade Native Staking -Now you can stake into Marinade Native via the SDK with or without referral code. +You can now stake assets in Marinade Native through the SDK, either with or without a 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. +If you choose to stake without a referral code, the methods exposed in `marinade-native-stake.ts` serve as wrappers for those already detailed in the [Native Stake SDK](https://www.npmjs.com/package/@marinade.finance/native-staking-sdk). +Please note that staking without a referral code will yield 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. +To acquire a referral code, you'll need to visit the [Marinade dApp](https://marinade.finance/app/earn/) to retrieve it. +Once you have the code, you can input it into the methods described below. Please note that the method returns a Versioned Transaction. Stake SOL to Marinade Native ```ts @@ -118,7 +117,7 @@ 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). +To initiate the process of unstaking, you'll need to merge your stake accounts back into a single account and pay the associated fee (in SOL). To do this, execute the following command: ```ts ... diff --git a/src/marinade-native-stake.ts b/src/marinade-native-stake.ts index 634d680..dd96473 100644 --- a/src/marinade-native-stake.ts +++ b/src/marinade-native-stake.ts @@ -11,11 +11,11 @@ import { } from './marinade-native-stake.types' /** - * Fetches the instruction to stake SOL in Marinade Native + * Retrieves the instruction for staking SOL with Marinade Native. * - * @param {PublicKey} userPublicKey - The PublicKey of the user - * @param {BN} amountToStake - The amount to deposit in lamports - * @returns {AuthStakeSOLIxResponse} - The instructions to add in transaction to stake in Marinade Native and new stake keypair + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. + * @param {BN} amountToStake - The amount to be staked, in lamports. + * @returns {AuthStakeSOLIxResponse} - The instructions to include in the transaction for staking in Marinade Native, along with the new stake keypair. */ export function getAuthNativeStakeSOLIx( userPublicKey: PublicKey, @@ -29,12 +29,12 @@ export function getAuthNativeStakeSOLIx( } /** - * Fetches the transaction to stake SOL in Marinade Native with refCode + * Retrieves the transaction for staking SOL with Marinade Native using a referral code. * - * @param {PublicKey} userPublicKey - The PublicKey of the user - * @param {BN} amountToStake - The amount to deposit in lamports - * @param {string} mNativeRefCode - Marinade Native referral code - * @returns {Promise} - The transaction to stake SOL into Marinade native using Referral Code + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. + * @param {BN} amountToStake - The amount to be staked, specified in lamports. + * @param {string} mNativeRefCode - The Marinade Native referral code. + * @returns {Promise} - A promise that resolves to the transaction for staking SOL with Marinade Native using the referral code. */ export async function getRefNativeStakeSOLTx( userPublicKey: PublicKey, @@ -51,11 +51,11 @@ export async function getRefNativeStakeSOLTx( } /** - * Fetches the instruction to stake Stake Account in Marinade Native + * Retrieves the instruction for staking a Stake Account with Marinade Native. * - * @param {PublicKey} userPublicKey - The PublicKey of the user - * @param {PublicKey[]} stakeAccounts - The stake accounts that are about to be deposited in Marinade Native - * @returns {TransactionInstruction} - The instruction to add in transaction to stake in Marinade Native + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. + * @param {PublicKey[]} stakeAccounts - The stake accounts to be used with Marinade Native. + * @returns {TransactionInstruction} - The instruction to include in the transaction for staking the Stake Account with Marinade Native. */ export function getAuthNativeStakeAccountIx( userPublicKey: PublicKey, @@ -66,12 +66,12 @@ export function getAuthNativeStakeAccountIx( } /** - * Fetches the transaction to deposit Stake Account in Marinade Native with refCode + * Retrieves the transaction for using a Stake Account with Marinade Native via a referral code. * - * @param {PublicKey} userPublicKey - The PublicKey of the user - * @param {PublicKey} stakeAccountAddress - The stake account to be deposited into Marinade Native - * @param {string} mNativeRefCode - Marinade Native referral code - * @returns {Promise} - The transaction to deposit Stake Account into Marinade native using Referral Code + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. + * @param {PublicKey} stakeAccountAddress - The address of the stake account intended to use with Marinade Native. + * @param {string} mNativeRefCode - The Marinade Native referral code. + * @returns {Promise} - A promise resolving to the transaction required for using the Stake Account with Marinade Native via the given referral code. */ export async function getRefNativeStakeAccountTx( userPublicKey: PublicKey, @@ -89,11 +89,11 @@ export async function getRefNativeStakeAccountTx( } /** - * Fetches the instruction to unstake from Marinade Native + * Retrieves the instruction for unstaking from Marinade Native. * - * @param {PublicKey} userPublicKey - The PublicKey of the user - * @param {BN} amountToUnstake - The amount to unstake in lamports - * @returns {UnstakeSOLIxResponse} - The instructions to pay the fee for unstake and the event that should be called after fee is paid in order to trigger unstake event faster (calling this is optional, but it ensures better experience for user). + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. + * @param {BN} amountToUnstake - The amount to be unstaked, specified in lamports. + * @returns {UnstakeSOLIxResponse} - The instructions for paying the unstaking fee and an optional event that can be called after the fee is paid to expedite the unstaking process (calling this event is optional but enhances the user experience). */ export async function getPrepareNativeUnstakeSOLIx( userPublicKey: PublicKey, @@ -104,9 +104,9 @@ export async function getPrepareNativeUnstakeSOLIx( } /** - * Calls the bot to rebalance user's funds (relevant especially right after the users deposits in Marinade Native, but not mandatory) + * Invokes the bot to rebalance the user's funds. This is particularly useful immediately following a deposit into Marinade Native, although it is not mandatory. * - * @param {PublicKey} userPublicKey - The PublicKey of the user + * @param {PublicKey} userPublicKey - The PublicKey associated with the user. */ export async function callRebalanceHint( userPublicKey: PublicKey