GithubHelp home page GithubHelp logo

juanxavier / autocompound_staking Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 5.31 MB

An ERC20 staking contract that allows for autocompounding rewards when multiple staking.

Makefile 0.07% Nix 0.01% Solidity 59.98% JavaScript 32.38% Ruby 7.25% Python 0.05% Shell 0.26%
blockchain erc20 ethereum evm smart-contracts solidity staking token

autocompound_staking's Introduction

WARNING: This code is not intended to be used in production/mainnets and it's not recommended to deposit real funds in it. Use at own risk.

About

This codebase uses the Foundry framework due to the overall benefits and speed of it as well as the requisites of the task. This project consists of an two main smart contracts:

  1. An ERC20 Token (Add3) that is Burnable, Mintable and Pausable. It allows only the owner to:
  • Mint an input amount of tokens to an arbitrary wallet.

  • Burn an input amount of only ERC20 Smart Contract owner’s tokens.

  • Pause the contract (by default the contract is not paused)

  1. A UUPS upgradeable staking contract hat once initialized, can be set to be Dynamic or Static, allowing to perform or not autocompound.

The architectural design chosen is to have a single ERC20 contract created (Add3) that will be used as staking token and as reward token in the staking contract, for simplicity reasons and to align with the test scenarios. In the following diagram you can find more detailed as per why the decision:

Architecture diagram

This project is deployed to the Mumbai testnet to the following addresses:

Add3 token:

https://mumbai.polygonscan.com/address/0x948e52b9aeec280c5a747db3b0d333c8e1277c8f#code

Add3Staking contract:

https://mumbai.polygonscan.com/address/0x4419b2a749a4e1642e554ebcd71fae67408ade42#code

The staking smart contract is particularly tested and deployed to the Mumbai network with the following values:

REWARD_RATE = 10;
STAKING_DURATION = 365 days;
MINIMUM_LOCK_TIME = 60 days;
MAX_TOTAL_SUPPLY = type(uint128).max  => Equivalent to 340282366920938463463374607431768211455;

This would represent an return of 10% over a period of 1 year (365 days) with a minimum lock time of 60 days, with availability for autocompounding when re-staking tokens.

Testing

As a pre-requisite, you must have Foundry installed: https://book.getfoundry.sh/getting-started/installation

To clone this repository and run the tests in a single line, run the following command:

In Windows Powershell

git clone https://github.com/JuanXavier/autocompound_staking ; cd ./autocompound_staking ; forge test

In Linux/Mac terminal

git clone https://github.com/JuanXavier/autocompound_staking && cd autocompound_staking && forge test

Or,

if the repository is already cloned, just run the following command:

forge test --vvv

This should run the following 57 tests:

Tests

Deployment

The contracts can be redeployed by running the following command:

forge script script/Deployment.s.sol:DeploymentScript --rpc-url $ENV:_MUMBAI --broadcast --verify --etherscan-api-key $ENV:_POLYGONSCAN_KEY -vvvv --legacy

NOTE: The test suite for this project is a work in progress and does not fully test all functionality yet. There are basic fuzzing tests for the Add3 token but a more extensive fuzzing and invariant testing of the staking contract can be made to better cover the codebase.

autocompound_staking's People

Contributors

juanxavier avatar

Watchers

 avatar  avatar

Forkers

augustoadd3

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.