Skip to content

Project📒 to demonstrate staking💰 of ERC20 based tokens over a period of time.

Notifications You must be signed in to change notification settings

steel-feel/simple-staking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Staking

Project📒 to demonstrate staking💰 of ERC20 based tokens over a period of blocks. Inspired from sushiswap masterchef staking protocol.

Working

  1. Staking contracts rewards Fixed amount per block set at depployment of contract.

  2. Reward calculation on each deposit/reward-withdrawal event.

  3. Staking Reward is calculated based on share of total staked token and total block rewards tokens ; since last event.

Share of token is calculated by

share = StakedToken/TotalStakedToken

Reward token calcucated by (happens at each event)

userA accumulated rewards = ( (rewardperBlock*blocks Passed) * userShare ) + previous accumated rewards

Example

A contract with 1 reward token per block.

Let say userA 10 tokens at block 5.

At Block 5

Status

userA staked token = 10 ,Total tokens = 10

At Block 10, userB joins the party

Status userA staked token = 10,userB staked token = 10,Total tokens = 20

Calculate rewards till the block

=> (1*5)*1 + 0

=> 5

At Block 15, userA harvest yields

Status userA staked token = 10 userB staked token = 10 Total tokens = 20

Calculate rewards till the block

=> (1*5)*0.5 + 5

=> 7.5

Usage

Installation

npm install

Deploy contracts

npm run deploy

Testing

npm test

About

Project📒 to demonstrate staking💰 of ERC20 based tokens over a period of time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published