snapshot-labs / snapshot-strategies

Snapshot voting strategies
https://docs.snapshot.org/strategies
MIT License
218 stars 753 forks source link

[garden-stakes] Add garden-stakes strategy #1492

Closed Revantark closed 3 months ago

Revantark commented 3 months ago

Changes proposed in this pull request:

Background

Getting the votes from the contract is not straightforward. First, we need to fetch the nonce of the user in the contract, which represents the number of stakes the user has. Then, we calculate an ID called stakeId, which is the hash of the user address and the nonce. Finally, we can get the user's votes by calling the stakes function with the stakeId. Users can have multiple stakes, so we need to iterate over all the stakes to get the total votes of the user.