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.
truffle develop // starts a local blockchain on port 7545
truffle test // runs the test
Install node
brew install node
(on Mac)
Install truffle
npm install -g truffle
-
Install dependencies
npm install
-
Start a local blockchain and deploy the contracts in truffle
truffle develop // starts a local blockchain on port 7545
truffle migrate // deploy the contracts
-
Start the nextjs server
npm run dev
-
Connect Metamask to the local netwotk on http://127.0.0.1:7545/
-
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
- The user page allows to stake, unstake LP tokens and claim a reward: