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
- Use the default configuration:
import { SolriseStaking } from '@solrise-finance/staking-sdk';
const solrise = new SolriseStaking({ publicKey: wallet.publicKey })
- 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,
isInitialized: true,
accountType: 2,
version: 1,
owner: publicKey,
count: 5,
totalStake: '5000000'
}
Get all staking accounts:
const accounts = await solrise.getStakingAccounts();
accounts = [
{
pubkey: publicKey,
isInitialized: true,
accountType: 1,
version: 1,
owner: publicKey,
tier: 2,
amount: '1000000',
amountUi: 1,
calculatedRewards: '13120',
createdAt: 1652624509,
lastUpdated: 1652624509,
state: 1,
apy: 16,
canWithdraw: false,
pendingReward: '13120',
pendingRewardUi: 0.01312,
unlocksInSeconds: 2583705
},
]
Create a new staking account:
const { transaction, signers } = await solrise.createStakingAccount(
tier,
amount,
yourSlrsTokenPublicKey
);
const signature = await signAndSendTransaction(transaction, signers)
Harvest reward (for tier 1 staking accounts only):
const { transaction, signers } = await solrise.harvestStakingAccount(
stakingAccountPublicKey,
yourSlrsTokenPublicKey
);
const signature = await signAndSendTransaction(transaction, signers)
Topup account (+ harvest reward if any):
const { transaction, signers } = await solrise.topupStakingAccount(
amount,
stakingAccountPublicKey,
yourSlrsTokenPublicKey
);
const signature = await signAndSendTransaction(transaction, signers)
Withdraw principal (+ harvest reward if any):
const { transaction, signers } = await solrise.withdrawPrincipal(
amount,
stakingAccountPublicKey,
yourSlrsTokenPublicKey
);
const signature = await signAndSendTransaction(transaction, signers)
Learn more