SNT Staking contracts
Go to file
Ricardo Guilherme Schmidt 9c38c50820
chore: update pull request template and README.md
2024-09-24 17:30:00 -03:00
.github chore: update pull request template and README.md 2024-09-24 17:30:00 -03:00
.vscode refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
certora refactor(certora): introduce shared.spec to reuse helper functions 2024-09-19 14:35:08 +02:00
contracts fix(StakeManager): change order of call of mintBonusMP to fix intended behavior. 2024-09-12 11:44:48 +02:00
lib refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
script feat(script): add deployment script for new `StakeManager`s 2024-02-29 11:19:18 -03:00
test test(StakeManager): add test to catch bug in minting more bonus MPs when stake with lock 2024-09-12 11:44:48 +02:00
.editorconfig refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.env.example refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.gas-report chore: update project description and author information, update README.md 2024-09-24 12:00:35 -03:00
.gas-snapshot chore: update project description and author information, update README.md 2024-09-24 12:00:35 -03:00
.gitattributes refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.gitignore chore(ci): add certora CI integration (#40) 2023-12-11 15:10:41 +01:00
.gitmodules refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.prettier.yml refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.prettierignore refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
.solhint.json refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
LICENSE Initial commit 2023-05-05 11:12:51 -03:00
PROPERTIES.md refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
README.md chore: update pull request template and README.md 2024-09-24 17:30:00 -03:00
codecov.yml refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00
foundry.toml chore(foundry.toml): update fuzzing settings 2024-09-23 06:10:17 -03:00
package.json chore: update project description and author information, update README.md 2024-09-24 12:00:35 -03:00
pnpm-lock.yaml chore: add adorno command to package.json 2024-09-10 13:05:06 +02:00
remappings.txt fix(remappings): add trailing slash to OZ remapping (#26) 2023-10-10 13:52:10 +02:00
slither.config.json refactor: migrate repository to foundry-template (#6) 2023-09-12 18:37:30 +02:00

README.md

@logos-co/stakingGithub Actions Codecov Foundry

Overview

This project is a smart contract system built for secure token staking and reward management on the Ethereum blockchain. It provides essential components for handling staking operations, managing rewards, and ensuring the security of staked assets. The system is designed to be robust, leveraging mathematical precision for reward calculations and secure vaults for asset protection.

Key Components

  • StakeManager: This contract handles the core staking operations. It is responsible for managing the staking process, calculating rewards, and tracking expired staking periods using advanced mathematical calculations. The contract utilizes OpenZeppelins ERC20 and math utilities to ensure accuracy and security.
  • StakeVault: This contract is responsible for securing user stakes. It facilitates the interactions between users and the staking system by ensuring that staked tokens are properly managed. The vault communicates with StakeManager to handle staking and unstaking operations while ensuring the safety of funds.

Features

  • Secure Staking: Users can stake tokens securely, with all interactions governed by the StakeVault and managed by StakeManager. StakeVault is actually owned by the user, and is the only account allowed to perform actions on it, where it store the staked tokens. StakeVault recognizes the validity of the StakeVault codehash to allow interacting with it, knowing that the code actually holds the tokens when it should.
  • Reward Estimation: The system provides accurate reward estimation, using mathematical formulas to calculate earnings based on staking time and amount.
  • Management of Expired Stakes: StakeManager tracks and manages expired staking periods, allowing for the efficient handling of staking cycles.
  • Integration with ERC20 Tokens: Built on top of the OpenZeppelin ERC20 token standard, the system ensures compatibility with any ERC20-compliant token.

Installation

To install the dependencies for this project, run the following command:

pnpm install

Usage

Staking Tokens

To stake tokens, the StakeVault contract interacts with the StakeManager. You can call the stake function from StakeVault with the desired amount and duration.

function stake(uint256 _amount, uint256 _time) external onlyOwner;

Managing Rewards

Rewards are calculated based on the staking period and amount. StakeManager provides functions to manage and track the reward process.

Security

The system is designed to protect staked tokens and ensure users assets remain safe throughout the staking process.

Development

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

Deploy to Anvil:

$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545

For this script to work, you need to have a MNEMONIC environment variable set to a valid BIP39 mnemonic.

For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

pnpm gas-report

Get a gas snapshot:

forge snapshot

Lint

Lint the contracts:

$ pnpm lint

Test

Run the tests:

$ forge test

Prepare to commit

Formats, generates snapshot and gas report:

pnpm adorno

License

This project is licensed under MIT.