- Node v16.13.2
This repository is used to develop, deploy, and test Dob smart contracts. Follow the steps below to get started.
First, install the necessary packages:
npm installNext, compile the contracts using Hardhat:
npx hardhat compileTo run the tests on the Hardhat default test network, use:
npx hardhat test The Hardhat configuration file defines settings for the following networks:
- Polygon mainnet ->
polygon - Polygon testnet ->
amoy - Celo Testnet ->
alfajores - Ethereum testnet (sepolia) ->
ethsepolia - Base mainnet ->
base - Base testnet (sepolia) ->
basesepolia
Some of these networks require you to provide RPC URLs in the .env file. Additionally, you will need to provide the private key of the deployer account in the .env file for each network. To help with this, an example .env file is provided.
We have created various Hardhat tasks to facilitate interaction with the contracts. These tasks are organized in the tasks folder with the following structure:
configs: Contains example config.jsonfiles used to run some tasks.utils: contains utility functions.task_dob_base: Contains dob-related taskstasks_erc20: contains ERC20-related taskstasks_tsm: contains TokenSaleMarket-related taskstask_currency: Contains Currency-related taskstasks_staking: Contains Staking-related taskstasks_simple_staking: Contains SimpleStaking-related taskstasks_dob_sale: Contains DobSale-related tasks
The currently existent Tasks are:
-
deployDobBase: A task to deploy base contracts for Dob enviroment -
deployERC20: task to deploy a ERC20 token and mint initial supply -
deployNewLogic: Deploys a new logic contract and link it to poolMasterConfig -
deployPools: A task to deploy a set of pools -
deployTreasuryDistributionPool: A task to deploy a new treasury pool -
estimateGasDeployDobBase: A task to estimate the deploy cost of base contracts for Dob enviroment -
getPoolInfo: get pool info -
transferToken: task to deploy the ERC20 Dob Token -
tsmBuyToken: tsmBuyToken -
tsmSetSale: tsmSetSale -
upgradePool: Upgrade a pool logic to a new implementation -
upgradePoolMaster: Deploys a new PoolMaster contract using UUPS upgradeable pattern -
upgradeTokenSaleMarket: Upgrade a token sale market logic to a new implementation -
configureSimpleStaking: Task to configure a new locked staking setting. -
configureStaking: Task to configure a new locked staking setting. -
deployDobBase: A task to deploy base contracts for Dob environment -
deployDobSale: Task to deploy the smart contract DobSale. -
deployERC20: Task to deploy a ERC20 token and mint initial supply -
deployNewLogic: Deploys a new logic contract and link it to poolMasterConfig -
deployNewPoolVersion: Deploys a new Pool logic version in the PoolMasterConfig -
deployPool: A task to deploy a pool -
deploySimpleStaking: Task to deploy the smart contract to manage locked staking. -
deployStaking: Task to deploy the smart contract to manage locked staking. -
deployToken: Task to deploy the ERC20 Dob Token -
deployTreasuryDistributionPool: A task to deploy a new treasury pool -
depositRewardSimpleStaking: Task to deposit reward tokens to the locked staking smart contract. -
depositRewardStaking: Task to deposit reward tokens to the locked staking smart contract. -
estimateGasDeployDobBase: A task to estimate the deploy cost of base contracts for Dob environment -
getPoolInfo: Get pool info -
getPoolMasterConfigInfo: Get poolMasterConfig info -
getProxyImplementation: Get the proxy implementation address -
setSharesLimit: Set the shares limit in the poolMasterConfig -
transfer: Task to transfer currency between holder address and toAddress -
transferOwnershipSimpleStaking: Task to transfer the ownership of a locked staking smart contract. -
transferOwnershipStaking: Task to transfer the ownership of a locked staking smart contract. -
transferToken: Task to transfer tokens between holder address and toAddress -
tsmBuyToken: tsmBuyToken -
tsmSetSale: tsmSetSale -
upgradePool: Upgrade a pool logic to a new implementation -
upgradePoolMaster: Deploys a new PoolMaster contract using UUPS upgradeable pattern -
upgradeTokenSaleMarket: Upgrade a token sale market logic to a new implementation
Each task includes documentation on any required or optional arguments. To get help for a specific task, run:
npx hardhat <task-name> --helpIn case you need to upgrade a pool master deploy, for example, the deploy_base_sepolia_testnet.json, the steps you need to follow are:
-
add the private key of the owner of the poolMasters to
.envfile under the keyACCOUNT_BASE_SEPOLIA. Here you can add as many private keys as you want -
compile the contracts with
npx hardhat compile
make sure to use node 16
-
execute the task to upgrade, for example, to upgrade our base sepolia deploy:
npx hardhat --network basesepolia upgradePoolMaster ./deploys/deploy_base_sepolia_testnet.json 0x5736E3A05b34214c4757fB331682e95fF67cCd5d
where the address must match the owner of the pool master and its private keys must be present in the environment variable
ACCOUNT_BASE_SEPOLIA. This task will deploy new logic versions forPoolMasterandPoolMasterConfig, and then execute the upgrade calls on the proxies. The new logic are stored in the same deploy file (./deploys/deploy_base_sepolia_testnet.json) as a new entry in a list of logic versions.
The poolMasterConfig has a pool logic version history structure, where it stores all the historic logic versions for pools. This allow for each pool to decide when and to what version should they upgrade. Each pool version will always be functional.
For example, to deploy a new pool version to our Base Sepolia Deploy we do:
-
add the private key of the owner of the poolMasters to
.envfile under the keyACCOUNT_BASE_SEPOLIA. Here you can add as many private keys as you want -
compile the contracts with
npx hardhat compile
make sure to use node 16
-
execute task to deploy new logic
npx hardhat --network basesepolia deployNewPoolVersion ./deploys/deploy_base_sepolia_testnet.json
The task will validate that the owner address (present in the deploy .json file) has its private key in the
.envfile. Once complete, the task will add the new logic version