blockchain-audit / labs

Our creative space
Other
1 stars 41 forks source link

T4-SOL Simple staking project #33

Closed henry-hz closed 6 months ago

henry-hz commented 8 months ago

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:

henry-hz commented 7 months ago