- Anyone can deposit any amount of wizard ($WZD) ERC20 tokens to their savings (staking) account.
- The Bank contract contains an additional token reward pool of
R$WZD tokens. - A staking reward is generated for the users, depending on the time passed before token withrawal.
- The contract is deployed at
t0 - The Bank owner sets a time period constant
T, used for reward calculation. - The owner also deposits an amount
Rof reward tokens, split into 3 subpools:
R1 = 20% of R, available after2Thas passed since contract deployment
R2 = 30% of R, available after3Thas passed since contract deployment
R3 = 50% of R, available after4Thas passed since contract deployment
The deposit period goes from t0 to t0 + T.
During this period, users can use the deposit method to save their $WZD tokens into the contract. After T has passed, no more deposits are allowed.
This period goes from moment t0+T to t0+2T
Users cannot withdraw their tokens (If the user tries to remove tokens before T time has elapsed since they have deposited, the transaction will fail).
After 2T has passed since contract deployment, the users can withdraw their tokens. However, the longer they wait, the bigger the reward they get. The amount of tokens each user receives will be proportional to their stake in the contract relative to the total staking for every time period.
There are three withdraw periods:
First Unlock --> from t0 + 2T to t0 + 3T
A user withdrawing during the first unlock will collect an additional amount of $WZD tokens from R1.
Second Unlock --> from t0 + 3T to t0 + 4T
A user withdrawing during the second unlock will collect an additional amount of $WZD tokens from R1 + R2.
Third Unlock --> from t0 + 4T
A user withdrawing during the second unlock will collect an additional amount of $WZD tokens from R1 + R2 + R3.
If no user waits for the third unlock to withdraw their tokens, the remaining tokens on the contract can be withdrawn by the bank (contract owner). In no other situation can the bank owner remove tokens from the contract.
Download the Hardhat repo and play around with tests, tasks or your own scripts:
git clone https://github.com/fields93/staking-bank.git
This project can run on:
🥇Hardhat Network
🥈Hardhat Localhost Testnet
🥉Ethereum Rinkeby Testnet
In the following sections, the different available interactions with each network wil be explained.
This network is used for testing.
yarn deploy
yarn test
Check the test coverage with the plugin Solidity Coverage:
yarn coverage
In order to interact with this network, you will first need to start a Hardhat Node in a different terminal:
yarn hardhat node
yarn deploy-localhost
yarn test-localhost
Both the Bank and the Wizard (ERC20 token) contracts have been already deployed and verified on Rinkebyscan at:
- Bank:
0x4B146B7AFcF4f5D74faedb71d6Ab41A7FF5ECa9e - Wizard:
0xA3048A8e2aabbdCe7A47685B8991EE58EeCeE47f
However, if you wish to deploy new contracts from your account and verify them, you can do it by running:
yarn deploy-rinkeby
To verify, first you will need to update the contract addresses in scripts/verify-contract.js and then run:
yarn verify
In this case, there are no available tests. Instead, some tasks have been added to the project in order to interact with the contracts deployed on Rinkeby. The available tasks are:
Get the balance of $WZD tokens in your wallet:
yarn task-balance
Mint tokens:
yarn task-mint AMOUNT
Deposit tokens:
yarn task-deposit AMOUNT
Withdraw tokens:
yarn task-withdraw AMOUNT
Retrieve tokens:
yarn task-retrieve AMOUNT