Socket
Socket
Sign inDemoInstall

@solrise-finance/staking-sdk

Package Overview
Dependencies
105
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @solrise-finance/staking-sdk

# solrise-staking-sdk


Version published
Weekly downloads
0
Maintainers
4
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 16 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc