Skip to content

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

License

Notifications You must be signed in to change notification settings

Kwame0/SolidityStake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published