Skip to content

A secure, gas-efficient single-pool staking contract with proportional rewards, adjustable emission rates, and delayed withdrawals. Features: prefunded reward reserves, same-token staking support, and governance-controlled parameters with timelock protection.

Notifications You must be signed in to change notification settings

TalismanSociety/seek-staking

Repository files navigation

Seek Staking Single Pool

Table of Contents

Requirements

  1. Install foundry

  2. Install make: Check if make is installed.

make --version

If not, install with homebrew:

brew install make
  1. Install libs:
make install
  1. Compile the project:
make build

Private Key Management

Add private key using Foundry wallet import & setup password:

cast wallet import defaultKey --interactive

View wallet list:

cast wallet list

Add the private defaultKey address and the name of choice for that wallet to .env, defaultKey was used in the example above:

SENDER_ADDRESS=0xAbC123
ACCOUNT_NAME=defaultKey

The password will be used for sending transactions through forge.

For more about private key security view ERC-2335

Environment Variables

Example .env file to interact with Ethereum mainnet/testnet and Polygon mainnet:

SENDER_ADDRESS=<your_address>
ACCOUNT_NAME=<account_name_for_SENDER_ADDRESS>

RPC_URL_ETHEREUM=<your_rpc_url_ethereum>
RPC_URL_ETHEREUM_SEPOLIA=<your_rpc_url_ethereum_sepolia>

RPC_URL_POLYGON=<your_rpc_url_polygon>

ETHERSCAN_API_KEY=<your_etherscan_api_key>
POLYGONSCAN_API_KEY=<your_polygonscan_api_key>

Variables to configure:

  • SENDER_ADDRESS: The address for the private key for your testnet wallet imported to keystore using Foundry. If you use MetaMask, you can follow this guide to export your private key. Note: This key is required for signing transactions like token transfers.
  • ACCOUNT_NAME : The name of the wallet associated with SENDER_ADDRESS. To view configured wallet names:
cast wallet list
  • RPC_URL_ETHEREUM: The RPC URL for the Ethereum mainnet. You can get this from the Alchemy or Infura website.

  • RPC_URL_ETHEREUM_SEPOLIA: The RPC URL for the Ethereum Sepolia. You can get this from the Alchemy or Infura website.

  • RPC_URL_POLYGON: The RPC URL for the Polygon mainnet. You can get this from the Alchemy or Infura website.

  • ETHERSCAN_API_KEY: An API key from Etherscan to verify your contracts. You can obtain one from Etherscan.

  • POLYGONSCAN_API_KEY: An API key from Polygon to verify your contracts on Polygon. See this guide to get one from Arbiscan.

Load the environment variables into the terminal session where you will run the commands:

source .env

Config File Overview

The config.json file within the script directory defines the key parameters used by all scripts. You can customize the token name, symbol, maximum supply, and cross-chain settings, among other fields.

Example config.json file:

{
  "owner": "0xAbC321",
  "staking": {
    "stakeToken": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
    "rewardToken": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
    "rewardRate": 1e18,
    "maxRewardRate": 5e18,
    "minRewardRate": 0,
    "rateChangeDelay": 604800,
    "withdrawDelay": 604800,
    "minStakeAmount": 1e18
  }
}

The config.json file contains the following parameters:

Field Description
stakeToken The address of the deployed stake token
rewardToken The address of the deployed reward token, same as stake token
rewardRate How many tokens are issued as rewards per second.
owner The address to own the contract.
maxRewardRate Maximum tokens issued as rewards per second
minRewardRate Minimum tokens issued as rewards per second (set to 0 to allow pausing)
rateChangeDelay Delay in seconds between proposing a new reward rate and executing it
withdrawDelay The minimum wait time between a user's withdrawal request and when they can complete it
minStakeAmount Minimum amount of tokens to stake

Testing

All local tests:

make test

To run specific test view available commands in Makefile

Deployment

Testnet:

Get some testnet tokens, go to Alchemy's faucet or your favorite faucet for the desired testnet network.

make deploy-staking ARGS="ethereumSepolia"

Mainnets:

make deploy-staking ARGS="ethereum"
make deploy-staking ARGS="polygon"

About

A secure, gas-efficient single-pool staking contract with proportional rewards, adjustable emission rates, and delayed withdrawals. Features: prefunded reward reserves, same-token staking support, and governance-controlled parameters with timelock protection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published