Does OpenZeppelin have staking pool contracts?

I am interested in developing a staking pool contract, along the lines of this one

from Illuvium. Does OpenZeppelin have any staking pool contracts along these lines?

I am also wondering if anyone knows to what extent the Illuvium staking pool contract is original. Did they use code from other existing staking pool contracts?

I do not think there is some stake contracts, but there are some talk about this, maybe you can have a look: Include a RewardDistribution Contract · Issue #2457 · OpenZeppelin/openzeppelin-contracts

1 Like

It actually looks like there was a vulnerability discovered in the Illuvium staking contracts, just one day after I made this post.

Maybe that's extra motivation for OpenZeppelin staking contracts!!

1 Like

We're looking into staking contracts but do not have one yet!

Can you describe the requirements that you'd be interested in? What are the primitive operations you would expect of a staking contract?

Assume we are staking MyToken (MTK) in return for MTK rewards. Here are some features I have in mind:

  • a staker (user) is assigned a weight, which increases as a function of the amount of MTK they stake and also increases as a function of the duration they choose to lock their MTK in the staking contract
  • a staker is continuously (however one wishes to interpret that on-chain) rewarded with MTK based on their weight as a fraction of the total pool weight
  • the total amount of MTK which is given out in rewards, per block (or more abstractly per second), is computed as some function of the MTK balance of a contract which holds the rewards
  • MTK rewards are classified as pending until the staker chooses to claim the rewards (so we are not making continuous MTK transfers)
  • the staking pool should last as long as the contract holding MTK rewards maintains positive balance (perhaps virtual positive balance, considering the notion of pending rewards)
3 Likes

This is great, thanks for sharing!

One of the biggest implementation challenges with this sort of contract seems to be enabling rewards with multiple tokens. In your requirements you specify a single MKR token for rewards, but have you considered this other possibility and do you think it could be important?

I'm not sure if you mean giving out multiple types of tokens as rewards, or if you mean staking multiple types of tokens.

However, I have considered the possibility of staking multiple types of tokens. So, in addition to just staking MTK, another reasonable situation is where users stake MTK-ETH liquidity tokens. The reason a protocol might want to do this is because giving out rewards for staking MTK-ETH liquidity tokens is a way to incentivize the creation of a liquid market.

But, as for the implementations I have considered, users would have to stake MTK and MTK-ETH in different pools, because I don't see any natural way to define "weight" which can apply simultaneously to both MTK and MTK-ETH token types. More specifically, although it is possible to instantaneously associate an MTK-ETH token with some corresponding amount of MTK, I don't see a way to define a conversion which is constant over time.

1 Like

I actually meant giving out multiple tokens as rewards.

But your point about staking LPs is very interesting as well.