Skip to content

A NextJS dapp to stake LP tokens into a pool contract and earn a reward in a reward token

Notifications You must be signed in to change notification settings

cpascoli/lp-token-staking

Repository files navigation

Staking Dapp for the ETB token

A Dapp to stake LP tokens into a pool contract and earn rewards tokens in return.

This project was developed for the "ETB Project #2" Hackathon organised by EatTheBlocks

The pool implements an efficient O(1) algo to distribute the rewards based on the paper calable-reward-distribution-paper

Features included:

  • The staking contract allows an admin to define multiple rewards periods. These are time intervals when a certain amount of reward tokens will be distributed to stakers.
  • Users staking their LP tokens into the pool during a reward period, will earn part of the allocated reward tokens.
  • The amount of reward tokens earned is proportional to the amount of tokens staked and the length of the staking period.
  • The pool contract will distribute reward tokens at a constant rate (e.g x reward tokens per second) amoung all active stakers.
  • Users can add and remove tokens from their staked amount at any time during a reward period. _ Users can claim their accrued reward tokens.
  • When users end their stake, they get back their LP tokens and all the reward tokens accrued so far.

To run the tests

truffle develop   // starts a local blockchain on port 7545
truffle test      // runs the test

Setup environment

Install node brew install node (on Mac)

Install truffle npm install -g truffle

To run the dapp locally

  1. Install dependencies npm install

  2. Start a local blockchain and deploy the contracts in truffle

truffle develop   // starts a local blockchain on port 7545
truffle migrate   // deploy the contracts
  1. Start the nextjs server npm run dev

  2. Connect Metamask to the local netwotk on http://127.0.0.1:7545/

  3. Access the dapp http://localhost:3000/

Note: Metamask has to be connected to the local truffle netowork on port 7545 :

 New RPC URL:  http://127.0.0.1:7545/
 Chain ID: 1337

User Page

  • The user page allows to stake, unstake LP tokens and claim a reward:

User Page

Stake Modal

Admin Page

  • The admin page allows to create a reward phase to distribute an allocated amount of reward tokens among stakers. Admin Page

About

A NextJS dapp to stake LP tokens into a pool contract and earn a reward in a reward token

Topics

Resources

Stars

Watchers

Forks