npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@solrise-finance/staking-sdk

v1.0.0

Published

# solrise-staking-sdk

Downloads

3

Readme

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