A contract owns 1,000,000 cloud tokens. Anyone who stakes cloud token into the contract starting on the beginDate and holds it for 7 days will receive a reward proportional their portion of the total stake at the expiration. For example, suppose Alice stakes 5,000 cloud token, but the total amount staked at expiration is 25,000 cloud coin. Alice will then be entitled to 200,000 of the rewards, because she accounted for 20% of all the users.
If you want to add inflation to your cloud token, you can just mint them. The solmate-erc20 has a mint fuction for you ready to use.
Warning: it’s very easy to accidentally compute the rewards in such a way that a malicious actor can abuse the system. Think carefully about the corner cases!
Example
Let's create a sequence of examples to illustrate the cashflow for the staking contract:
Scenario 1: Early Bird Staking
Stakers:
Staker 1: Stakes 5,000 tokens on day 2 (beginDate + 1)
Staker 2: Stakes 10,000 tokens on day 3 (beginDate + 2)
Staker 3: Stakes 7,000 tokens on day 5 (beginDate + 4) - Too late to participate in this round
Rewards:
Staker 1: After 7 days (on day 8), calculates a reward of 1,666,666 tokens (assuming total stake remains 15,000) - [(5,000 * 1,000,000) / 15,000]
Staker 2: After 7 days (on day 8), calculates a reward of 3,333,333 tokens (assuming total stake remains 15,000) - [(10,000 * 1,000,000) / 15,000]
Staker 3: Receives no reward since their stake was placed after the 7-day window.
Scenario 2: Late Staking
Stakers:
Staker 1: Stakes 5,000 tokens on day 5 (beginDate + 4)
Staker 2: Stakes 10,000 tokens on day 6 (beginDate + 5)
Staker 3: Stakes 7,000 tokens on day 7 (beginDate + 6)
Rewards:
Staker 1: After 7 days (on day 12), calculates a reward of 1,250,000 tokens (assuming total stake is 22,000) - [(5,000 * 1,000,000) / 22,000]
Staker 2: After 7 days (on day 12), calculates a reward of 2,500,000 tokens (assuming total stake remains 22,000) - [(10,000 * 1,000,000) / 22,000]
Staker 3: After 7 days (on day 12), calculates a reward of 1,750,000 tokens (assuming total stake remains 22,000) - [(7,000 * 1,000,000) / 22,000]
Key Takeaways:
Stakers are rewarded proportionally to their contribution to the total stake during the 7-day window.
Staking earlier increases the chance of a larger reward since the total staked amount might be lower.
Staking after the 7-day window disqualifies users from receiving rewards in that particular round.
Stake Together
A contract owns 1,000,000 cloud tokens. Anyone who stakes cloud token into the contract starting on the beginDate and holds it for 7 days will receive a reward proportional their portion of the total stake at the expiration. For example, suppose Alice stakes 5,000 cloud token, but the total amount staked at expiration is 25,000 cloud coin. Alice will then be entitled to 200,000 of the rewards, because she accounted for 20% of all the users.
If you want to add inflation to your cloud token, you can just
mint
them. The solmate-erc20 has a mint fuction for you ready to use.Warning: it’s very easy to accidentally compute the rewards in such a way that a malicious actor can abuse the system. Think carefully about the corner cases!
Example
Let's create a sequence of examples to illustrate the cashflow for the staking contract:
Scenario 1: Early Bird Staking
Scenario 2: Late Staking
Key Takeaways: