- Install npm dependencies:
npm install
- Install foundry according to Foundry Book Installation Page
- Compile smart contracts:
forge build
- Format code:
forge fmt
- Run test:
forge test
- Run single test with prefix testTotal:
forge test -vvv --match-test testTotal
- Run test in forked network:
forge test --fork-url https://[NODE_PROVIDER]
User can stake in pre-defined ERC20 token and earn
veQoda balance will be computed , so no claiming is needed to
There is no lock-up period in place, but to encourage continuous staking, unstaking for any method at any point of time will reset all veQoda balance to 0.
For reward distribution, reward at each epoch will be distributed according to account ve / total ve. Ve balance will be calculated automatically without user explicitly claiming token. To avoid iterating all user accounts to deduce total ve at the end of each epoch, total ve will be calculated as follow:
Terminology:
- Staked token amount of Account A =
S(A)
= StakingInfo.amount - Last ve balance of Account A =
LS(A)
= StakingInfo.amountVe - Last ve claim time of Account A =
T(A)
= StakingInfo.lastUpdateSec - Reward distribution rate =
R
= MethodInfo.vePerDay
So by keeping track of following upon balance update:
[LS(A) + LS(B) + ...]
= MethodInfo.totalVe[S(A) + S(B) + ...]
= MethodInfo.tokenAmount[S(A) T(A) + S(B) T(B) + ...]
= MethodInfo.tokenAmountTime
Total ve at any given time can be calculated as totalVe + (tokenAmount * time - tokenAmountTime) * vePerDay
, as shown in totalVe()
of VeQoda contract
To support multiple ve per day distribution, tokenAmount, tokenAmountTime and vePerDay should be stored separately
- All contract implementations should be made upgradable (except QodaToken) so DAO can propose upgrade to it.
- If for-loop is used, make sure looping condition is exposed as parameter to avoid breaching gas limit upon iteration, unless number of entries is guaranteed to be small.
- Any account can act on behalf on another account to facilitate support, unless the operation will damage benefit of target account (e.g. unstake).
- Coding style should follow Solidity Style Guide and NatSpec Comment Format