cryptosteer / eatthestake

Staking DApp for Eat The Blocks Projects hackathon #2.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eat The Stake

Staking DApp for Eat The Blocks Projects #2.

screenshot

Install

  1. Install truffle/contract dependencies:
yarn install
  1. Install client:
cd client
yarn install

Unit tests

truffle test

Run

  1. Run ganache:
ganache-cli
  1. Deploy contracts:
truffle migrate --reset
  1. Start front end:
cd client
yarn start
  1. If you'd like to pass 15 days in your Ganache blockchain, execute the following 2 lines at truffle console:
timestamp = (await web3.eth.getBlock(await await web3.eth.getBlockNumber()))['timestamp']
advancetime = new Promise((resolve,reject) => { web3.currentProvider.send({jsonrpc:'2.0', method: 'evm_mine', params: [timestamp+60*60*24*15], id: timestamp}, (err, result) => { if (err) { return reject(err) } return resolve(result); }) })

Known issues/limitations

  • The DApp was designed for ETB token and Pancakeswap LP tokens. So it only supports 18 decimal tokens, and no support for tokens with fee on transfer and other esoterica.
  • For some reason, when running the unit tests, truffle takes around 1:30 minutes before it even reaches the initial compilation stage. I'm not sure if it's a local error or something with Truffle. Anyway, this does not happen when running deployment.
  • In the truffle tests it is tricky to test for balances, as we are calculating based on seconds and sometimes there is 1-3 seconds of delay. See here Gotacha#2 for explanation. To combat this, when testing time sensitive functions, I allow the actual result to be within 3 (monetary unit allocated per second) error of margin from the expected result.

Misc

  • The contract is based upon SushiSwap's MasterChef.
  • In the development network, the contract deploys 2 mock ERC20 contracts and mints tokens for the first Ganache accounts, for testing. The first account will be the owner who is allowed to add rewards, and the next 2 accounts can be used for staking and testing. These contracts (ERC20Factory and MockERC20) will not be deployed to networks other than local dev networks.

About

Staking DApp for Eat The Blocks Projects hackathon #2.


Languages

Language:JavaScript 72.5%Language:Solidity 17.1%Language:CSS 6.9%Language:HTML 3.5%