GithubHelp home page GithubHelp logo

marcoreliooo / mystackingdapp Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.17 MB

Basic Stacking dapp with back in Solidity and front in reactjs and web3 libraries

Solidity 32.05% JavaScript 64.18% HTML 3.12% CSS 0.65%
defi ethereum solidity

mystackingdapp's Introduction

MyStackingDapp

Goals : be able to

  • Create an ERC20 token for rewards
  • Stake/Unstake ERC20 tokens, DAI, USDC, w/e ERC20 ;)
  • Use the ERC20 created for rewards
  • Rewards quantity muwt be proportionnal to the blocked value in the smart contract
  • Using Chainlink Oracle to get a true price

Stack IT

  • Back folder : solidity smart contracts, openzeppelin library, chainlink...
  • Front folder : react app

Rewards calculation

For this app we use a reward calculation based on the staking time elapsed and proportionnaly with the total supply of the token type staked. Rewards are determined at 3 places :

  • When a user restake an amount of a previously staked token, it computes the reward for this token for the time elapsed before restaking the token but do not transfer it to the user.
  • When a user unstakes a previously staked token : it computes the rewards of that token and mint it to the user and unstake the token.
  • When a user presses the getReward button, it does not unstake. It only computes the rewards of that token, and mint it to the user.

The basic formula is then : DailyRewardRate * (currentTs - updatedTs) * price(token) * quantity(token) / totalPrice(token) * 100 * 3600 Where

  • RewardRate stands for the rate of the rewards token the user will get.
  • currentTs : block.timestamp
  • updateTs : timestamp updated since last staking or last computation of rewards
  • price(token) is given by ChainLink Oracle
  • totalPrice(token) is given by ChainLink Oracle

What I learn doing this app ?

  • Better calculate the reward as a percent of the token staked, and transforms it in a price reward of the "reward token" when user claims it
  • Better mint rewards than create a limited supply, as with time, the amount of supply will decrease, thus the rewards too. This is counterproductive as we expect a staking application to give us more rewards the longer we stake...
  • Don't forget to use try catch to get chainlink prices

What would be the next step ?

  • What can we do with the staked tokens users have deposited ? Take them and stake them elsewere ?
  • To ensure users come to our platform we should think about incentive too

mystackingdapp's People

Contributors

marcoreliooo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.