-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERC900: Simple Staking Interface #900
Comments
Do we want a |
@shrugs good point, seems like it could be important. I’ll add it |
It would just be |
@izqui good point, but maybe for consistency sake it makes sense |
Is it worth using Interface Detection instead of |
I feel like in this scenario a simple boolean function is more readable, than an interface detection function. |
Is there a staking protocol you can link to that is in a state where all the variables and rules are completely fleshed out? I just want to make sure this interface covers all the bases / actually applies to where it may be used. |
@AtLeastSignificant This standard grew out of something built for both Harbour and Aragon, we've tried to build it as generically as possible. The previous implementation from aragon has been reworked to fit to this standard. |
@decanus Gotcha. Unfortunately, I'm not familiar enough with this to have very valuable input on your interface without a more concrete protocol to reference. One thing I noticed though - the |
@AtLeastSignificant the wording I used in the Updated the text a bit |
@decanus hmm, then perhaps an |
Well a user would still need to call unstake, splitting |
I was more suggesting that It could just be that |
I wouldn't call it Would like to hear @izqui's opinion on this. |
We have a very similar staking contract; see here for reference. |
Cool initiative. I'm just thinking that for the |
@cbruguera No that's not possible, a user needs to execute that manually. |
@christoph2806 Looks interesting, looks like a lot of your code work with the interface we have defined. I've seen a bunch of contracts that have this awfully similar interface. |
@cbruguera a solution that might help, there's so called Staker just calls this function on the token contract providing the address of the staking contract as StandardToken contract
Staking contract
We're using this pattern at Keep network and it works nicely 😀 Let me know if you need any further info, happy to help |
@AtLeastSignificant @decanus I really like the idea of having asynchronous @ngrinkevich The problem with I would be however happy to extend this standard in a way that allows you to stake by doing a ERC777 or |
How do you expect this to work in systems that have eg minimum staking periods? I'd expect something like Many staking schemes I've seen need to be able to extend how long funds are at risk after certain staker behavior. If we build infrastructure around this I'm not sure how tools would cope without another standard. |
@mhluongo I might be missunderstanding but unstake could just revert if you haven’t staked for a minimum amount of time. |
I'm not doing a great job explaining 😊 Our unstake process has a delay. Once you've claimed you want to unstake, you can't fully withdraw from the staking contract for 2 weeks. It's to prevent certain attacks where triggering slashing conditions are delayed- if stakers can quickly unstake, they can avoid getting slashed. |
Is it intentional that Maybe something like |
@johnhforrest Our definition is currently that method, I find it dangerous if you can stake for someone but then also unstake those tokens you have staked. Could lead to some weird issues, I think. Of course if you need it differently you could do so in your own contract. Additionally you could limit |
I don't think having an That being said, I do agree that something didn't feel quite right in the implementation I was writing where users could stake multiple times. I've added some logic now that each address staking tokens can only have a single stake. This stake can be for themselves, or for another address. |
Sorry, there was an error in my response. I meant unstake. |
@decanus Just finished my interpretation of the standard here: https://github.com/codex-protocol/contract.codex-registry/blob/master/contracts/ERC900/ERC900BasicStakeContainer.sol With a battery of tests here: https://github.com/codex-protocol/contract.codex-registry/blob/master/test/core/CodexStakeContainer.test.js Would love to get your feedback & potentially include it in the implementations section if it's worth sharing. We took a different approach where staked tokens (even if staked for another address) always belong to the originator. Users can create multiple stakes, and can receive annualized interest on the perceived value of their stakes by pinging the contract after sufficient time has passed. The intent is that these would be long-term stakes that provide benefits to the user based on the amount of perceived tokens staked. |
@johnhforrest This sounds interesting, I will need to have a full look a little later. Feel free to add your implementation to the EIP, as it is merged you can add a PR. |
Hey @decanus! I was wondering how useful this simple staking interface can be applied for the creation of masternodos through this standard? |
I agree with @johnhforrest that staked tokens should always belong to the originator, even if they are staked to another user (stakeFor). This enables a couple of important use cases:
What are the use-cases where someone would use stakeFor, and want the recipient to own their tokens when they unstake? This doesn't feel an implementation detail. There should be consistency over what unstake() will do. If there are legitimate reasons for transferring ownership when tokens are staked to another user, it should probably have a different function to when they are just delegated. |
I keep coming across this need to get a list of staked addresses and their corresponding balances for a staking contract I'm working on. Perhaps we can have an optional method that does one of the following:
and/or
When another contract is using this standard, as say an owner, it's likely such a aggregate will have to be constructed to be consumed. With the current standard there isn't a way to do this except if you know the address beforehand. This doesn't imply you must implement this of course if you don't want anyone to know the stakers in a direct way so I don't think it'll break the current design. |
FYI I sent a PR to add another reference implementation here: #1212 Reference implementation is located here: |
@tavakyan I am not sure whether this should be defined in the ERC itself, however it does not prevent you from implementing something like this on your own as it doesn’t really break compatibility. |
@decanus In my case I was trying to come up with an interface that a validator set contract can use to interact with all the stakers for the purposes of a PoS-like consensus engine. Perhaps this is better left for a future standard since this is supposed to be a 'simple' interface. I got this idea when looking at some code in the melonproject project: https://github.com/melonproject/smart-contracts/blob/develop/src/system/OperatorStaking.sol <-- see getStakersAndAmounts() |
There has been no activity on this issue for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review. |
This issue was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment. |
Preamble
Abstract
The following standard describes a common staking interface allowing for easy to use staking systems. The interface is kept simple allowing for various use cases to be implemented. This standard describes the common functionality for staking as well as providing information on stakes.
Motivation
As we move to more token models, having a common staking interface which is familiar to users can be useful. The common interface can be used by a variety of applications, this common interface could be beneficial especially to things like Token curated registries which have recently gained popularity.
Specification
stake
Stakes a certain amount of tokens, this MUST transfer the given amount from the user.
The data field can be used to add signalling information in more complex staking applications
MUST trigger
Staked
event.stakeFor
Stakes a certain amount of tokens, this MUST transfer the given amount from the caller.
The data field can be used to add signalling information in more complex staking applications
MUST trigger
Staked
event.unstake
Unstakes a certain amount of tokens, this SHOULD return the given amount of tokens to the user, if unstaking is currently not possible the function MUST revert.
The data field can be used to remove signalling information in more complex staking applications
MUST trigger
Unstaked
event.totalStakedFor
Returns the current total of tokens staked for an address.
totalStaked
Returns the current total of tokens staked.
token
Address of the token being used by the staking interface.
supportsHistory
MUST return true if the optional history functions are implemented, otherwise false.
lastStakedFor
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns last block address staked at.
totalStakedForAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns total amount of tokens staked at block for address.
totalStakedAt
OPTIONAL: As not all staking systems require a complete history, this function is optional.
Returns the total tokens staked at block.
Implementation
Copyright
Copyright and related rights waived via CC0.
The text was updated successfully, but these errors were encountered: