1.3.5 • Published 2 years ago

brc20-staking-sdk-test v1.3.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

BRC20-STAKING-SDK

A JavaScript SDK for calculating BRC20 staking rewards.

Usage

// typescript
import {
  getRewards
} from "brc20-staking-sdk-test";

// user amount
const userAmount = "24000000000000000000000000000"
// token decimal
const decimal = 18 
// user unclaimed rewards
const pendingRewards = "0"
// pool type (fixed or pool)
const ptype = "pool"
// accumulative reward per shared
const accRewardPerShare = "555120952548"
// tracks the amount of rewards that the user has already earned
const rewardDebt = "13194448645776000000000"
// block height of the latest update for the pool
const lastUpdateBlock = 800134
// current block height
const currentBlock = 800187
// pool rate: number of reward tokens generated per block
const erate = "100000000000000000000"
// total amount currently staked in the pool
const totalStakeAmount = "13370852348120000000000000000000"
// the number of T20-S tokens already minted for this pool
const minted = "188400000000000000000000"
// the maximum number of T20-S tokens that can be issued for this pool, where minted <= dmax
const dmax = "21000000000000000000000000" 
  
const currentRewards = getRewards(
                                    userAmount, 
                                    decimal, 
                                    pendingRewards, 
                                    ptype,
                                    accRewardPerShare, 
                                    rewardDebt, 
                                    lastUpdateBlock, 
                                    currentBlock, 
                                    erate, 
                                    totalStakeAmount,
                                    minted,
                                    dmax
                                )
  
console.log("currentRewards:", currentRewards) // 137967445848000000000
1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago