0

Staking algorithms and rewards scheme

If it needs to be developed,
is there any common source of truth on how to implement this or everyone making their own one?

If governance contract needs some tokens to be locked to make a vote and
this amount is supposed to be taking part in staking and getting rewards for the time being in the lock
Does it mean that this amount should be locked in the state of Staking contracts or transferred
from Token user balance to the Staking contract user balance?

1 Answer 1

1

There are few questions to answer before considering to build governance contract:

  • are you really ready to store users tokens in your contract?
  • if yes then, when voting has ended who is going to pay for the staked amount to go back to users wallets?

Let's start from here - by default every voting is giving the right for person or group of people to express an opinion. Voting is always related to picking one of the provided options. It makes sence for the voting to have end so that the results of the vote itself can be analyzed.

Why I'm saying this, I had to built few weeks ago a voting system, but I didn't really wanted my contract to lock user tokens for security reasons ( I sleep better this way ) and secondly I didn't want to pay the tx costs for the tokens which has to be returned into voters wallets once the voting is over. So in my vote method instead of asking the voter to lock his ERC20 amount into my contract what I'm doing is:

  1. checking if the voter has the amount that he is voting with ( there're few other validations like for example one voter can vote only once, etc )
  2. if yes, then I save the voting amount into mapping for this voter

Now on the voting end date you can take a snapshot which checks if all of the voters are still owners of the token amount that they voted with. In my contract such snapshop method is getPollVotes. This method is filtering only the valid voters by the time of the voting end date. The snapshot is preventing voter trying to vote twice from 2 or more addresses using same token amount.

You can find my contract code here https://github.com/mnedelchev-vn/Decentralized-Governance-Poll. However do not fully trust my code as it is still in testing phase, I'm just sharing the concept with you. I will be happy to see other concepts.

2
  • Miroslav, thank you for your input, very enlightening. I had the same thoughts regarding keeping tokens in the user's wallets, although, some questions occur 1) what if a user decides to withdraw all tokens from the wallet balance? It won's affect governance but the state in governance will not be valid 2) Governance needs to be stateful to avoid adding proposal, voting and snapshoting at the same time. Commented Dec 17, 2020 at 23:05
  • Hey Dmitry, about 1) it's true, if user moved his tokens after voting the snapshot will remove him when returning the voting result, but the state of the contract will stay let's call it no synced to the valid results. We can solve this by adding new logic in the snapshot method - while looping thru all voters, to remove the votes of voters which has moved their tokens before the voting end. About 2) The solution from 1) will sync the voting data in the state of the smart contact. I was originally thinking to save the results data in a external database, but this option looks better now. Commented Dec 18, 2020 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.