@solrise-finance/staking-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Solrise

solrise-staking-sdk

Solrise.finance SLRS token staking SDK.

This SDK allows easy fetching, parsing and staking/unstaking your SLRS tokens

Contents:

Installation

$ npm install @solrise-finance/staking-sdk

Examples

Initialize the library

  1. Use the default configuration:
import { SolriseStaking } from '@solrise-finance/staking-sdk';

const solrise = new SolriseStaking({ publicKey: wallet.publicKey })
  1. Use other configuration options:
import { SolriseStaking } from '@solrise-finance/staking-sdk';

const solrise = new SolriseStaking({
  publicKey: wallet.publicKey,
  connection: web3connection
})

Staking

Get aggregate staking account (shows sum of all your stakes):

const aggregate = await solrise.getAggregateStakeAccount();

aggregate = {
  pubkey: publicKey,    // account public key
  isInitialized: true,  // account initialized
  accountType: 2,       // 2 means its aggregate account
  version: 1,           // version
  owner: publicKey,     // your wallet
  count: 5,             // number of your stake accounts
  totalStake: '5000000' // total SLRS staked in your stake accounts
}

Get all staking accounts:

const accounts = await solrise.getStakingAccounts();

accounts = [
  {
    pubkey: publicKey,          // account public key
    isInitialized: true,        // account initialized
    accountType: 1,             // 1 means its staking account
    version: 1,                 // version
    owner: publicKey,           // your wallet
    tier: 2,                    // see tiers explanation
    amount: '1000000',          // amount of SLRS tokens
    amountUi: 1,                // amount but divided by decimals
    calculatedRewards: '13120', // SLRS rewards when lockup is finished
    createdAt: 1652624509,      // account created
    lastUpdated: 1652624509,    // account updated (harvest, topup, withdraw)
    state: 1,                   // state ?
    apy: 16,                    // APY
    canWithdraw: false,         // if true - you can withdraw principal + reward
    pendingReward: '13120',     // pending reward for harvest when tier is 1
    pendingRewardUi: 0.01312,   // same as above but divided with decimals
    unlocksInSeconds: 2583705   // lockup expiration in seconds for tiers 2-5
  },
  // ...
]

Create a new staking account:

const { transaction, signers } = await solrise.createStakingAccount(
  tier,                     // tier is number 1 - 5
  amount,                   // number of SLRS
  yourSlrsTokenPublicKey    // SLRS token account owned by your wallet
);

const signature = await signAndSendTransaction(transaction, signers)

Harvest reward (for tier 1 staking accounts only):

const { transaction, signers } = await solrise.harvestStakingAccount(
  stakingAccountPublicKey,  // publicKey of staking account you are harvesting
  yourSlrsTokenPublicKey    // SLRS token account owned by your wallet
);

const signature = await signAndSendTransaction(transaction, signers)

Topup account (+ harvest reward if any):

const { transaction, signers } = await solrise.topupStakingAccount(
  amount,                   // number of SLRS to add to staking account
  stakingAccountPublicKey,  // publicKey of staking account you are harvesting
  yourSlrsTokenPublicKey    // SLRS token account owned by your wallet
);

const signature = await signAndSendTransaction(transaction, signers)

Withdraw principal (+ harvest reward if any):

const { transaction, signers } = await solrise.withdrawPrincipal(
  amount,                   // number of SLRS to withdraw
  stakingAccountPublicKey,  // publicKey of staking account you are harvesting
  yourSlrsTokenPublicKey    // SLRS token account owned by your wallet
);

const signature = await signAndSendTransaction(transaction, signers)

Learn more

Readme

Keywords

none

Package Sidebar

Install

npm i @solrise-finance/staking-sdk

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

111 kB

Total Files

58

Last publish

Collaborators

  • sljuka
  • veloja
  • vsakos
  • vidor
  • turshija
  • zlajaa