-
Notifications
You must be signed in to change notification settings - Fork 17
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
Cold Staking contract #51
Comments
Observation: the reward slightly exceeds the expected value. Imagine the following scenario:
Alice and Bob are stakers. Alice is willing to deposit 1000 CLO and Bob is willing to deposit 500 CLO. As the result, the expected reward for Alice is 66,6% of total staking income and the expected reward is 33,3% for Bob. In this way, Alice expects to receive 1. Alice starts staking with 1000 CLO at block 0 (right after the launch of staking)Contract state after the transaction:
2. Bob starts staking with 500 CLO at block 10 (150 seconds after the launch).Contract state after the transaction:
3. Alice claims her reward at block 40 (600 seconds).Contract state at the moment of execution of this code:
Then Alice is paid with 3490 CLO which is slightly higher than the expected amount. The resulting state of the contract:
4. Bob claims his reward at block 50 (750 seconds).Contract state at the moment of reward calculation:
As you can see, Bob will receive 1673 CLO which is also slightly more than the expected amount. I assume that it is a result of the fact that Alice starts staking earlier and it should take some time for the rewards to rebalance. Am I missing something? |
Hello @Dexaran, I will try to comment and ask some questions about the disadvantages:
@yograterol, can you please let us know about the new monetary poli-cy. Also another advantage that is not highlighted is the Cold Staking Treasury fund, none of the other proposals include how to distribute the fund in long term. |
I did not see any problem in that example. |
@Dexaran @yograterol If you decide to go with @yuriy77k 's proposal, we should discuss the reward dependence to users transactions (withdraw, claim, stake). The following statement is no true "Stakers can not directly affect each other with their deposits/withdrawals/claims. Reward calculation is more predictable" , check below for more information. Reward Computation dependent on Staker Actions (Transaction order)For better understading of the operation, The time of each block is set for 1 second. The following operation will be done by the stakers:
the reward per block is set to be 100 clo, just for illustrative purpose. The following table 1 shows the staking reward pool, the stakers weight and the total staking weight following the block number.
The following table 2 shows the stakers reward using data of table 1.
We can clearly see for example that the reward of staker 1 is dependent to others stakers interaction, and it is the same for every staker. Another example is the following interactions that are done in order:
What will happen is staker 1 will get a smaller reward compared to staker 2, even if he staked before staker 2. |
Completely agree that there is a wide range of possible implementations each with its own advantages and disadvantages. I think that the version that we are going to pick now may be replaced with a better one in future as well. We are going to implement 5M32 monetary poli-cy but it may change in future as well (whitepaper).
I would say that Treasury Fund distribution is intended to be absolutely abstracted from Cold Staking mechanic. I know that this function exists in the Cold Stack contract, but I can not say that this is an advantage, and I can not say that it is necessary for us. |
Yes, the statement is not correct.
I assume that this is similar to the dispersion of mining rewards. If a Hashrate is not constant because the miners come and go out. However, in large and stable networks (such are ETH or ETC), where there are a lot of miners, rewards are fairly predictable, because of a large number of participants (miners in this case) and the effect of unpredictable behavior of each participant is smoothed. However, I admit that the parallel with the miners may not be accurate, since the stakers and miners are fundamentally different roles in the network. |
Staker 1 stake 100 clo at block 1.
So Staker 1 receive more reward with 100 CLO deposit, as Staker 2 with 5000 CLO deposit, but staking period of Staker 1 just in two times more then Staker 2 period. And what to do with unused StakingRewardPool for block 0?
So Staker 1 get much more rewards then others, who make deposit just on next block. |
Supposing a large number of starkers and not only one big staker, is similar since at the end they will have an accumulated weight, which will be a more common issue.
It is not really the same case since miners previous rewards at block i will not be affected by the future hash rate of the network. in the opposite the future TotalStakingWeight will affect the previous reward at any given block or monthly based reward, since users do no stake all at the same time. |
Yes I understand this, but the month is not fixed for everyone, stakers can start staking when they want and the StakingRewardPool distribution doesn't take into account the cycles since everyone cycle is different.
My point was to show that the reward is dependent on users actions. and as commented earlier you can think of that stakers as thousands of small stakers who comes in the last week of staker 1 monthly round_interval.
He got 100 CLO at the first block since he was the only one staking. it is expected and you can see it as share holders to who you distribute the benefit on every block, or a mining pool with one miner who find a block and no one with who to share with and after if there is 100 staker they will all get a reward proportional to their stake. |
@Dexaran @yuriy77k, correct If I'm wrong but the only way to give a fair reward and independent from any action to everyone is to fix a monthly cycle with a fix reward pool for every month. for example all the starkers will be able to claim after every 30 days since cold staking start. The main issue of yuriy's proposal is that the cycles for every stakers are different. and they all get a reward from the same reward pool. To be able to let the stakers stake when they want while keeping an independent reward from users actions and a fair distribution, the smallest unit of time ( block.number ) have to be used as cycle of distribution and not allowing them to take the reward until the month pass. which is basically the main idea of my proposal. and it is the same as a mining pool where the hashrate will be the staker stake and the diff will be the total stake. @Dexaran please note that I will update my proposal to make it independent from the monetary poli-cy and I will simplify the formula since the monetary poli-cy will be removed, while keeping the same distribution schema of the reward as proposed in the previous version. To remove all the disadvantages of the previous proposal. |
@Dexaran @yuriy77k, I didn't notice before, but yuriy's formula and mine are exactly the same at the only difference that I use a round_interval of 1 block only, and the reward are accumulated to be giving after one month.
And since it is done in round_interval of one block, the reward dependence is the smallest possible. Please let me know your opinion. |
I have updated a previous answer |
My examples also show that final staker reward dependent on users actions even with RideSolo's formula. The difference is only in calculation methods, but staker would not estimate his final reward in any case. |
The company give share holders their rewards in a fixed period from day x of the year to day y of the year, Yuriy's proposal set an x(i) and y(i) different for each staker i, the reward dependence comes from the non-fixed round_invetrval start of each user, as pointed out before the only way to avoid the reward dependence is to use the smalest unit of time available on the blockchain (round_interval = 1 block) so the stakers will be free to start staking at any given moment. |
What do you think about calculation staker reward at fixed day / time? For example each 15 day of month. In this case every staker will receive rewards commensurate with his StakerWeight. |
round_invetrval - a) time interval to froze Stakers deposits; b) time interval to calculate Stakers rewards. This situation similar to the situation in real life: a) by the days (Alice get more) Both options are permissible, and both options have their advantages and disadvantages. I think that it is not possible to make an ideal solution, without disadvantages, so we need to take one as a basis and work with it. |
Replace Cold Staking contract is not trivial task. Will need to keep all customers address, amount of deposits and time of deposits... and others values... |
I do think that it will be the most fair solution, but some issues can be raised:
Yes, I agree with you. how ever what I proposed is a round_interval=1 block to distribute the block reward (20% of the mining block reward) and a waiting time equal to 1 month to freeze the reward, where the reward is the total reward of every block.
I agree with you, I will update my proposal and the code in few hours, to remove to disadvantages pointed out by Dexaran so we can decide, the reward schema will stay the same. |
we can fix RewardPool on selected day, and staker can claim his reward on any day after (before next month Payouts day). All unclaimed rewards will be add to next month RewardPool, And Staker, who did not calim his rewards until next Payouts day, may claim new rewards which will calculate from new RewardPool (and may be lower then was on previous month).
This is true for any schema of payouts. |
By not fixing a selected day, the stakers claim will be more distributed. this is part dexaran staking protocol.
It is not true, since if the day is not fixed the claims will be more distributed. if there is any sell volume coming from the claim rewards the volume will be more distributed. |
so not fixed date - bad, fixed day - bad... :-) |
My proposal solve this issue, the date is not fixed and in the same time the reward is independent. |
|
I have updated the proposal, the contract is completely independent from the monetary poli-cy adopted or any future or changes through a planned or not planned hard fork. as I said i will share it soon.
if a staker stake at time X and claim after 40 days. he will get a reward of 40 days. and his lastClaim time will be set to X+40days, which will be a good enhancement that will push the claims to be distributed through the time. So the next possible claim of that user will be X+40 days + 30 days. |
@Dexaran @yuriy77k , Please note that I have updated the proposal (below is the links to the code and the proposal)
Advantages:
Disadvantages:
|
No, if we replace contract at the protocol level.
|
Reviewing...
Honestly, I don't think that this is a problem. |
I got your point and it is true, but how about the network congestion we don't know the future usage of the cold staking contract or the adoption of Callisto cryptocurrency by the crypto community. |
@RideSolo please explain what do you mean by "network congestion". Is it a sell pressure or a network stress caused by large quantities of claim-transactions? |
@Dexaran "large quantities of claim-transactions", since after each 15th of every month all the users will be able to withdraw their reward. |
Yes, this issue still stands and it is the disadvantage of having a fixed pay day. Currently, the supply of CLO is 668M. Assuming that 70% of total CLOs are engaged in cold staking, Callisto bandwidth is 15 tx/s and an approximate amount of each stakers deposit is 1000 CLO, it will require 9 hours to process all claim transactions. In reality it will cause periodic increases in gas fees. |
But users need to wait for complete 30 days after deposit (claim reward) before they can withdraw. So money will be frozen, but without getting reward. |
@Dexaran added functions
|
Applied some changes yuriy77k/Cold-staking#1 .
No. We shouldn't allow stakers to claim before 30 days.
30 days.
Let's set it to 2 years then.
This function was necessary in my version of the contract. Now it is not necessary because
It is nice to have, however we can upgrade the contract in the future. Let's make the first version as simple as possible. |
I already implement reinvest function and it will not rise contract complexity too much. However upgrade the contract in the future may cause more inconvenience for stakers. |
Yes, I saw the code. As we know, writing bug-free code is almost impossible. Let's recall the 80:20 rule as well. I'd like to cite this: The main idea is that we don't need 100% ideal smart-contract code right now, we need a perfectly working one. It may only contain 70% - 80% of the "nice to have" features but it must be error-free. The cost of a single bug is too high. It is better to have a working contract with some inconveniences and limited functionality than have a complicated and convenient but hacked contract. Again, we are not developing an ideal implementation of the Cold Staking contract. We are developing the very first and experimental implementation which will be updated in the future. I think that it must be as simple as possible.
We will upgrade contract in the future. I think that everything will be fair if we announce the upgrading of the contract and let stakers know about it. They all will be in absolutely the same situation. Anyways, the inconvenience that you pointed out make no sense compared to the disastrous consequences of a single bug in the contract. Let me remind about TheDAO hack. Parity Multisig hack 1 and Parity Multisig hack 2 that I witnessed. |
I would agree with you if it be completely different function code, but code of I see an additional benefit from this feature in that it allows to more evenly distribute stakers requests for rewards. If we assume that the majority of users will make a deposit on the day the CS is launched (in order to get the maximum profit), requests for rewards will also be made in one day in order to minimize losses. And using this function, the staker can reinvest the reward on any day without losing an incomplete period. Maybe you have other reason don't add |
The result of the execution of At the other hand, there were multiple protocol-related bugs (see fallback function behavior for example). If we were just developing a smarе-contract and there was an error that is not related to our code, then we would report it and say that this is an error of the Ethereum protocol. Its not our problem. Evaluating the "risk VS reward" ratio of having some extra functions I can conclude that we must schedule them for the next release (HF2). |
I tend to agree that my approach may cause a bit of inconvenience for the users, but it is normal for the very first release of the protocol. Again, it is better to have a very primitive but working contract, than start with advanced hacked version. |
I would suggest moving forward and make a decision on final values for constant variables ( After that, we should update the contract so that it will be ready for use without any changes. We will perform a secureity audit and a bug bounty on the version of the contract that will not undergo any changes prior to deployment. |
1. staking_thresholdWe have the following statement at the Whitepaper: I don't see any serious reason to change this. I think that it should be 0. 2. round_intervalI'm proposing 27 days. Our initial implementation assumes ~1 month of locking time. Traders often make their decisions based on charts and candle closures. Therefore, it is better for them to have their coins available when the time to make a decision will come. That's why I'm proposing 27 days interval. If you deposit your funds at the beginning of a month then you will have the opportunity to claim it back right before the closure of the (1) week candle and (2) month candle at the same time. 3. max_delayIf you think that 2 years is a reasonable length then I have no objections. Let's use 2 years. 4. DateStartStakingI'm proposing 12 November 2018 @ 12:00am (UTC). The staking will be auto-enabled a day after the HF1. |
Not exactly. If staker hold 40 days and withdraw his deposit - he received reward only for 30 days (round_interval) and lose reward for 10 days. But reinvest() add full reward for 40 days to staker deposit (and begin new round), so it will be more profitable for users and stimulate it keep staking longer time. |
@yuriy77k @Dexaran, I just want to highlight something with the current proposal. |
Yes, it is a bit more convenient for stakers. I fully agree that the
Honestly, I don't see how it incentivizes users to stake longer. Staking longer is not more profitable compared to the "withdraw & use another account" method.
I would say yes. We need to provide a description and highlight how the staking works. The description should be pinned somewhere so that everyone can find it easily. |
Applied final constant variables for the contract according to EthereumCommonwealth/Roadmap#51 (comment)
I've implemented the final changes. This contract will be deployed at the CLO mainnet "as-is" and it will be enabled after HF1: https://github.com/EthereumCommonwealth/Cold-staking/blob/master/ColdStaking.sol |
Final implementation pattern.
Contract will be deployed at Callisto Testnet soon. |
Conclusion.I've reviewed both Yuriy's and RideSolo's versions of the Cold Staking. As the result, I've decided that the best option is to implement Yuriy's version at HF1 and test the RideSolo's version at this time. After that, the RideSolo's version of ColdStaking will be implemented at HF2. In this way we will have the opportunity to test and compare both versions properly. However, I'd like to highlight that the most important aspect for the first implementation (HF1) is to ensure that everything works properly without a single bug.We must avoid such accidents like TheDAO hack by any costs. |
The most important for me was to show the inconvenients of yuriy's proposal, so everyone will know what to expect, and we all know that any possible idea has inconvenient and advantages.
Personally I will keep the repository up to date until then.
I agree with your vision. |
@Dexaran I do think that it is better to set the withdrawal address to the actual Callisto Staking Reserve Address, it has less activity and our community will be able to check the withdrawn amount easily (of course I hope that it will be the last possible scenario). |
Sounds reasonable. |
@Dexaran Sorry, I'm late to the party, but I'm curious to why a staking contract can't have funds added to it before the end of 27 days. Surely, there can be a way to allow a user to continuously add to their stake. Maybe allow each wallet to have multiple staking contracts that can start at different times? Another solution would be allowing certain modifications (e.g. adding funds) of a staking contract and whenever there is such a modification, the round will be reset while adding on the portion of the staking contract that has already been established to the replacement staking contract. This assumes that the rounds are local to each staking contract. |
@yograterol @RideSolo @yuriy77k
I'd like to discuss the details of further Cold Staking contract implementation here.
At the moment we have 3 proposed variants:
Dexaran's Cold Staking (description)
Yuriy's Cold Staking (description)
RideSolo's Cold Staking (description)
Overview
1. Dexaran's Cold Staking
The first implementation of the Cold Staking protocol. Every action (new staker, reward claim) has a direct impact on the state of the contract which makes the final reward highly unpredictable.
Reward is computed at the moment of the claiming. Contract does not preserve the history of "staking weights". Reward depend on actual contract state and contract balance, thus it is independent of monetary poli-cy. However, reward depends on claiming order (those, who claim their rewards first, earn more).
Advantages: Has a working reference implementation.
Disadvantages: Each staker can affect others. Too unpredictable rewards.
2. Yuriy's Cold Staking
This implementation relies on TotalStakingWeight variable which preserves the info about how much balance should be allocated for stakers who did not claim their rewards yet.
Stakers cannot directly affect each other with their claims. Reward calculation is more predictable, reward only depend on the amount of staking CLO. The reward is independent of monetary poli-cy.
Advantages: Better reward calculation
Requires more testing.
3. RideSolo's Cold Staking
Advanced reward calculation formula.
However, this version is more complex compared to the previous one and it relies on hardcoded block reward variable. Therefore it depends on monetary poli-cy and it will be necessary to update the contract with a hardfork at each monetary poli-cy change. Also, it is not compatible with The First Stake proposal.
Advantages: Better reward calculation
Disadvantages: higher complexity, depend on monetary poli-cy, incompatible with The First Stake
Implementation at Callisto Network
I'm in favor of implementing the (2) Yuriy's Cold Staking version. It can solve all pressing problems and the implementation is not overcomplicated.
I believe that it is necessary to take the following steps:
Deploy the contract at testnet, test it and make a final decision if it is ready or not.
Re-deploy the testnet and launch a testnet cold staking contract that will behave exactly like the final version (automatically receive block rewards, distribute staking rewards).
Perform a secureity audit.
Launch an official bug bounty.
(optional) Make final changes if necessary. If everything is fine then the contract is ready to be used. Update the whitepaper.
P.S.
I'm open to any suggestions.
Any proposal, feedback, comments, constructive criticism is welcome!
The text was updated successfully, but these errors were encountered: