A Linear Vesting Yield Mechanism
To prevent mev frontrunning the staking yield, we introduce a change where rewards will vest linearly over 8 hours. This means staking yield can only be transferred every 8 hours, and the total assets within each 8-hour period will increase linearly.
Terminology
VestingPeriod - 8 hours
VestingAmount - all rewards transferred during each VestingPeriod
UnvestedAmount - the rewards that will not be counted in the total assets of the staking contract until the next epoch
Formula:
TimeSinceLastDistribution = CurrentTimestamp - LastDistributionTimestamp UnvestedAmount = ((VestingPeriod - TimeSinceLastDistribution) * VestingAmount) / VestingPeriod
Example
Initial Case
User Alice holds 100 slUSD
User Bob holds 500 slUSD
0 slUSD inside the staking contract, USDs = 0 slUSD
User Stake
Alice stakes 100 slUSD
100 slUSD inside the staking contract, USDs = 1 slUSD, Alice receives 100 USDs
Reward Transferred In
50 slUSD rewards are transferred into the staking contract
The 50 slUSD will all be UnvestedAmount, and USDs = 1 slUSD still
Right After 5 Hours
Now UnvestedAmount is ((8 - 5) * 50) / 8 = 18.75
USDs = (100 + 50 - 18.75) / 100 = 1.3125 slUSD
Bob stakes 500 slUSD, USDs = 1.3125 slUSD, Bob receives (500 / 1.3125) ≈ 381 USDs
Since the current epoch hasn't ended, there is still an UnvestedAmount, and no new rewards can be transferred into the staking contract.
Right After 8 Hours (Current Epoch Ends)
The current epoch ends, the UnvestedAmount is reduced to 0, USDs = (100 + 500 + 50) / ((500 / 1.3125) + 100) ≈ 1.3515 slUSD.
Last updated