Skip to content

A simple defi dapp. DAI be staked and unstaked. Another token provided to stakers.

License

Notifications You must be signed in to change notification settings

lilixac/yieldfarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Defi


This is a dapp for yield farming.

It involves 2 ERC20 tokens:

  • DAI Token (DAI)
  • My Token (MAI)

MAI is out token farm specific token that the investors can earn by staking their DAI.

During the time of token distribution, the investors earn the tokens that they staked in our dApp.

The investors can invest a certain number of DAI Tokens, and unstake specific number of DAI tokens at any point of time.

The script for MAI token issuance can be run by the owner only. At specific times, the owner runs the script, and all the stakers get the same amount of MAI as the number of DAI staked.


Tested using local blockchain at port 8585 (Ganache)

Load the second account in the ganache to metamask. In the script for deployment, the second account gets 100 DAI.

I played around with it before. So, the staked, reward and available balance are not equal to 0 DAI,0 MAI and 100 DAI.

Image 1

Staking 20 DAI: Image 2 You need to confirm transaction via metamask.

Run the script to reward stakers.

truffle exec scripts/issue-mytokens.js

Refresh the page. Now, the staker will get MAI equal to staked balance as reward. Previously, the staker had 3 MAI as reward and 1 DAI as staked balance. When 20 DAI is staked, total staked balance is 21 DAI. Now, when the reward is issued, staker gets 21 MAI as reward, and thus has (21+3) = 24 MAI now.

Image 3

Now, let's unstake all 21 DAI and and try to reward the stakers. Metamask transaction needs to be confirmed. Image 4

Now, run the script to reward stakers. Since the staked balance is 0, this address won't get any more MAI.

About

A simple defi dapp. DAI be staked and unstaked. Another token provided to stakers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published