update readme

This commit is contained in:
CounterFire2023 2024-08-30 17:10:54 +08:00
parent 4a1ce5e30b
commit 774fdd85ff
10 changed files with 256 additions and 137 deletions

View File

@ -1,13 +1,46 @@
# Sample Hardhat Project
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
## Contracts for Staking
Try running some of the following tasks:
### tokens/erc20/EsToken.sol
```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.ts
```
Escrowed CEC(esCEC) token contract. This contract is a ERC20 token contract with additional functionality, with `inPrivateTransferMode = true` the token can only be transferred by the address with `isHandler = true`. This is used to prevent the token from being transferred while the token is in escrow.
Escrowed CEC(esCEC) tokens can be converted into CEC tokens through vesting.
There are two ways to earn esCEC tokens:
1. staking CEC tokens;
2. staking esCEC tokens;
### staking/RewardRouter.sol
Main contract for staking. This contract is used to stake CEC tokens and esCEC tokens. The contract will distribute rewards to the stakers based on the amount of tokens staked and the duration of the stake.
Each staked Escrowed CEC token will earn the same amount of Escrowed CEC as a regular CEC token.
After staking, the staker will receive esCEC tokens every second, the staker can claim the rewards at any time.
The staker can unstake the tokens at any time. The staker will receive the staked tokens and the rewards.
### staking/RewardTracker.sol
Actuary contract for staking. This contract is used to calculate the rewards for the stakers. The contract will calculate the rewards based on the amount of tokens staked and the duration of the stake.
### staking/RewardDistributor.sol
Distributor contract for staking. This contract is used to distribute the rewards to the stakers. The contract will distribute the rewards based on the amount of tokens staked and the duration of the stake.
### staking/Vester.sol
With this contract, the stakers can convert their esCEC tokens into CEC tokens.
esCEC tokens that have been unstaked and deposited for vesting will not earn rewards. Staked tokens that are reserved for vesting will continue to earn rewards.
After initiating vesting, ths esCEC tokens will be converted into CEC every second and will fully vest over `365 days` (based on the `vestingDuration` variable). esCEC tokens that have been converted into CEC are claimable at anytime.
With `needCheckStake` set to `true`, the contract will check if the staker has enough staked CEC tokens before initiating vesting.
Depositing into the vesting vault while existing vesting is ongoing is supported.
Tokens that are reserved for vesting cannot be unstaked or sold. To unreserve the tokens, use the "withdraw" method. Partial withdrawals are not supported, so withdrawing will withdraw and unreserve all tokens as well as pause vesting. Upon withdrawal, esCEC tokens that had been vested into CEC will remain as CEC tokens.

View File

@ -65,12 +65,6 @@ contract RewardRouter is ReentrancyGuard, Governable {
function claim() external nonReentrant {
address account = msg.sender;
IRewardTracker(stakedCecTracker).claimForAccount(account, account);
}
function claimEsCec() external nonReentrant {
address account = msg.sender;
IRewardTracker(stakedCecTracker).claimForAccount(account, account);
}

View File

@ -1,5 +1,5 @@
{
"address": "0x2824Dc12495f86349430099939282b48aeDD6036",
"address": "0x249A2FB61507FDf31C9110eC55a38185f826069D",
"abi": [
{
"inputs": [
@ -450,18 +450,18 @@
"type": "function"
}
],
"transactionHash": "0x794009fab84f1226c6050bc4f42883823309b0901aed47f16d4fc55fa2faafa6",
"transactionHash": "0xaa83a4fd97b9a436242fe8eb86ae84448445d197a603bf537baf8c5b6dca696a",
"receipt": {
"to": null,
"from": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"contractAddress": "0x2824Dc12495f86349430099939282b48aeDD6036",
"contractAddress": "0x249A2FB61507FDf31C9110eC55a38185f826069D",
"transactionIndex": 0,
"gasUsed": "993001",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0xd8f84018634952a81dad4926dc625fccfc1fd45db1734d789c321633563fd87f",
"transactionHash": "0x794009fab84f1226c6050bc4f42883823309b0901aed47f16d4fc55fa2faafa6",
"blockHash": "0x549bc69f0d432152468edd1e8da63be13fa7cb6ea9a4238e456a6a6a56115fbb",
"transactionHash": "0xaa83a4fd97b9a436242fe8eb86ae84448445d197a603bf537baf8c5b6dca696a",
"logs": [],
"blockNumber": 43372868,
"blockNumber": 43429406,
"cumulativeGasUsed": "993001",
"status": 1,
"byzantium": true

View File

@ -1,5 +1,5 @@
{
"address": "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
"address": "0x089D17189f5Ccdf8efA3CB9541509bFbCDEc4c28",
"abi": [
{
"inputs": [
@ -228,25 +228,25 @@
"type": "function"
}
],
"transactionHash": "0x596a9d19bedfedcfd6dda6a255bc4135f2cbe06cdab77e4f4938d807f3ef44f2",
"transactionHash": "0xb1a326b50c4b8f7980a2aa34a5a5a9a79c5b5c986597317d1c53042c7bc47ef7",
"receipt": {
"to": null,
"from": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"contractAddress": "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
"contractAddress": "0x089D17189f5Ccdf8efA3CB9541509bFbCDEc4c28",
"transactionIndex": 0,
"gasUsed": "701322",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x5a2b3f6b05be2d0fdaa97847f0b0eea06edcee180f00c410115c8d4d4c804006",
"transactionHash": "0x596a9d19bedfedcfd6dda6a255bc4135f2cbe06cdab77e4f4938d807f3ef44f2",
"blockHash": "0x99292ccc6f1c78a50363c7b3b0eea0db12868ed4f62f61586f7d65f6eecfc5db",
"transactionHash": "0xb1a326b50c4b8f7980a2aa34a5a5a9a79c5b5c986597317d1c53042c7bc47ef7",
"logs": [],
"blockNumber": 43372886,
"blockNumber": 43429428,
"cumulativeGasUsed": "701322",
"status": 1,
"byzantium": true
},
"args": [
"0x2824Dc12495f86349430099939282b48aeDD6036",
"0xEA374dC9f94E7A3A2eE8C0C910954cE15E2C469E"
"0x249A2FB61507FDf31C9110eC55a38185f826069D",
"0xBe6F99d816dF9E6861b2501f90aFC615bd77b674"
],
"numDeployments": 1,
"solcInputHash": "35d1d20dc9b7194768908e34f12939fd",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
{
"address": "0xF7AaF4b166E11146F4D44c91B2a3818Ada13CdFB",
"address": "0x75AAedeD5311AC5752AA625E5e90cCe962C37D8f",
"abi": [
{
"inputs": [
@ -937,19 +937,19 @@
"type": "function"
}
],
"transactionHash": "0x450133cf5830d1a0f3a051964f9f01615f9c602660f9c6beeeab108d5b4853f4",
"transactionHash": "0x1df41c07cb50f54b160b3b0de680224fcc34f2033c2dd8448492bd597f0da79c",
"receipt": {
"to": null,
"from": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"contractAddress": "0xF7AaF4b166E11146F4D44c91B2a3818Ada13CdFB",
"transactionIndex": 0,
"contractAddress": "0x75AAedeD5311AC5752AA625E5e90cCe962C37D8f",
"transactionIndex": 1,
"gasUsed": "1803252",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0xbcd61437d0b157cd8ccfb5aa1456c22a1e6aadebb4a7d7d81fc412307252b3a4",
"transactionHash": "0x450133cf5830d1a0f3a051964f9f01615f9c602660f9c6beeeab108d5b4853f4",
"blockHash": "0x4a0c8e93117ce39a3738a573577c146df3e7f3eba74688218082747bbe4c8eb4",
"transactionHash": "0x1df41c07cb50f54b160b3b0de680224fcc34f2033c2dd8448492bd597f0da79c",
"logs": [],
"blockNumber": 43372895,
"cumulativeGasUsed": "1803252",
"blockNumber": 43429436,
"cumulativeGasUsed": "1873973",
"status": 1,
"byzantium": true
},
@ -957,10 +957,10 @@
"Vested CEC",
"veCEC",
"31536000",
"0x2824Dc12495f86349430099939282b48aeDD6036",
"0x249A2FB61507FDf31C9110eC55a38185f826069D",
"0x0000000000000000000000000000000000000000",
"0xe34c5ea0c3083d11a735dc0609533b92130319f5",
"0xEA374dC9f94E7A3A2eE8C0C910954cE15E2C469E",
"0xBe6F99d816dF9E6861b2501f90aFC615bd77b674",
true
],
"numDeployments": 1,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,46 +23,46 @@
"json": "assets/contracts/FT.json",
"address": "0xe34c5ea0c3083d11a735dc0609533b92130319f5"
},
{
"name": "TokenClaim",
"type": "logic",
"json": "assets/contracts/TokenClaim.json",
"address": "0xC95bDFAaFBf79b435e4d2bF8d77842fc19e6fE56"
},
{
"name": "rewardTracker",
"type": "logic",
"json": "assets/contracts/RewardTracker.json",
"address": "0x5aB49C4b7e21e35fD4fd05affB019320a95cb03D"
},
{
"name": "TokenClaim",
"type": "logic",
"json": "assets/contracts/TokenClaim.json",
"address": "0x35556DDFfa4586ce25Da5CaC7dCA845cD780F8b4"
},
{
"name": "esCEC",
"type": "erc20",
"json": "assets/contracts/EsToken.json",
"address": "0x2824Dc12495f86349430099939282b48aeDD6036"
"address": "0x249A2FB61507FDf31C9110eC55a38185f826069D"
},
{
"name": "stakedCecTracker",
"type": "logic",
"json": "assets/contracts/RewardTracker.json",
"address": "0xEA374dC9f94E7A3A2eE8C0C910954cE15E2C469E"
"address": "0xBe6F99d816dF9E6861b2501f90aFC615bd77b674"
},
{
"name": "stakedCecDistributor",
"type": "logic",
"json": "assets/contracts/RewardDistributor.json",
"address": "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5"
"address": "0x089D17189f5Ccdf8efA3CB9541509bFbCDEc4c28"
},
{
"name": "vester",
"type": "logic",
"json": "assets/contracts/Vester.json",
"address": "0xF7AaF4b166E11146F4D44c91B2a3818Ada13CdFB"
"address": "0x75AAedeD5311AC5752AA625E5e90cCe962C37D8f"
},
{
"name": "rewardRouter",
"type": "logic",
"json": "assets/contracts/RewardRouter.json",
"address": "0xa57131c08c7E13abAB9Dd95721d456E1C2895b64"
"address": "0x38a73851249827B26fF597D1160A461dfE373578"
}
]