@soceanfi/stake-pool-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.4.6 • Public • Published

Socean

GitHub branch checks state npm-version npm-license Discord Twitter

Socean Stake Pool Typescript SDK

Socean Stake is a liquid staking protocol built on Solana that delivers the highest risk-free yields on Solana through Socean’s algorithmic delegation strategy. Users can stake their SOL tokens with the Socean Stake Pool and receive scnSOL tokens in return. These scnSOL tokens can be used across Solana’s DeFi ecosystem or can be swapped back to SOL anytime.

This SDK provide a client to interact with the staking protocol and allows you to stake and unstake through socean stake pool within your applications.

Contents:

Installation

npm

$ npm install @soceanfi/stake-pool-sdk

yarn

$ yarn add @soceanfi/stake-pool-sdk

Examples

Initialization

Import the main client class Socean and initialize it with the desired cluster type:

import { Socean } from "@soceanfi/stake-pool-sdk";

// initializes for mainnet-beta
const socean = new Socean("mainnet-beta");

// or for testnet
const socean = new Socean(); // or give 'testnet' as the argument

// you can also use a custom rpc endpoint
const socean = new Socean("mainnet-beta", "https://myawesomerpc.com:8899");

// or you can also use your own Connection object
const connection = new Connection(clusterApiUrl("mainnet-beta"));
const socean = new Socean("mainnet-beta", connection);

Retrieve on-chain state

const stakePoolAccount = socean.getStakePoolAccount();

Stake SOL and Receive scnSOL

Frontend (react example):

import { Socean, Numberu64 } from "@soceanfi/stake-pool-sdk";
import { useWallet } from "@solana/wallet-adapter-react";
import { FC } from "react";

const socean = new Socean("mainnet-beta");

const StakeOneLamportWithSoceanButton: FC = () => {
  const wallet = useWallet();

  const onClick = async () => {
    const signatures = await socean.depositSol(wallet, new Numberu64(1));
  };

  return <button onClick={onClick}>Stake one lamport with Socean</button>;
};

Unstake scnSOL and Receive Stake Accounts

Frontend (react example):

import { Socean, Numberu64 } from "@soceanfi/stake-pool-sdk";
import { useWallet } from "@solana/wallet-adapter-react";
import { FC } from "react";

const socean = new Socean("mainnet-beta");

const WithdrawOneDropletFromSoceanButton: FC = () => {
  const wallet = useWallet();

  const onClick = async () => {
    const { transactionSignatures, stakeAccounts } = await socean.withdrawStake(
      wallet,
      new Numberu64(1),
    );
  };

  return (
    <button onClick={onClick}>
      Withdraw one droplet (1 / 10 ** 9 scnSOL) from Socean
    </button>
  );
};

Learn more

Package Sidebar

Install

npm i @soceanfi/stake-pool-sdk

Homepage

socean.fi/

Weekly Downloads

16

Version

0.4.6

License

MIT

Unpacked Size

471 kB

Total Files

105

Last publish

Collaborators

  • 0xf812
  • sloaf
  • socean