GithubHelp home page GithubHelp logo

kwame0 / soliditystake Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 2.0 31 KB

SolidityStake is a simple solidity scaffolding library for providing User Staking Data when Staking ERC20 or ETH to a Smart Contract

License: MIT License

Solidity 100.00%
ethereum-contract openzeppelin openzeppelin-solidity solidity solidity-codes solidity-contracts staking staking-contract yield yield-farming

soliditystake's Introduction

SolidityStake v1

SolidityStake is a simple solidity scaffolding library for providing User Staking Data when Staking ERC20 or ETH to a Smart Contract

Features Include

  • Staking and Unstaking

  • Setting a Minimum Staking Amount

  • Setting a Staking Fee

  • Owner Unstake all Users

  • Owner Contract Renunciation

  • Custom Error Messages

  • Total Staker Count

  • Getting User Staking Amount

  • Getting User Lifetime Staking Amount

  • Getting User Joindate

  • Getting User Staking Percentage

  • Builtin User Yield Variables

You can also easily loop through each staker (see UnstakeAll() function)

sETH.sol (For Staking Native ETH/AVAX/BNB/MATIC etc)
sTOKEN.sol (For Staking Tokens)

NOTE: Requires OpenZeppelin Contracts
npm i @openzeppelin/contracts

Implementation Example

contract SolStakeEth is ReentrancyGuard, Ownable {
  ...
  uint256 public fees_collected;
  ...
  function Stake() external nonReentrant payable {
    ...
    uint256 fee = (eth * 1000) / 10000;
    fees_collected = fee;
    LendToAAVEorCURVEetcETC(fee);
    ...
  }
}

contract myContract is SolStakeETH {
  ...
    function FeesCollected() public view returns (uint256){
      return fees_collected;
    }
  ...
}

When calling the contract via ethers.js

await myContract.Stake({ value: ethers.utils.parseEther("1000") });
let total_fees = ethers.utils.formatEther(await myContract.FeesCollected());
let bal = ethers.utils.formatEther(await myContract.GetStakingAmount(staker.address));
console.log(bal); // 900
console.log(total_fees); // 100

Warning: These smart contracts have not been audited, use at your own risk!

soliditystake's People

Contributors

kwame0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.