forked from snapshot-labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[holds-tokens] Combined meebits strat (snapshot-labs#85)
* Fix example and readme in meebitsdao strategy * holding token strategy * meebit strat not working * fix rpc issue, but strat still broken * snapshot voting working * changes to readme * change readme * rever package-lock.json * fetching the block number if we are not using latest * updating readme * updating token strategy to utilize multicall and erc20-with-balance * remove console.log * Update src/strategies/holds-tokens/examples.json Co-authored-by: Chaitanya <[email protected]> * add comma to example Co-authored-by: Josh Peters <[email protected]> Co-authored-by: Patrick Lu <[email protected]> Co-authored-by: lightninglu10 <[email protected]> Co-authored-by: Chaitanya <[email protected]>
- Loading branch information
1 parent
b858b6a
commit a8bba53
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# holds-tokens | ||
|
||
This strategy return the balances of the voters for a specific ERC20 or ERC721 and maps them to the number of votes that voter gets based on holding a set of tokens. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"tokenAddresses": [ | ||
{"address": "0x7Bd29408f11D2bFC23c34f18275bBf23bB716Bc7", "network": "1", "decimals": 0, "minBalance": 1}, | ||
{"address": "0xc34cbca32e355636c7f52dd8beab0af2396ebd79", "network": "137", "decimals": 0, "minBalance": 1} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "holds-tokens", | ||
"params": { | ||
"symbol": "ABC", | ||
"tokenAddresses": [ | ||
{"address": "0x7Bd29408f11D2bFC23c34f18275bBf23bB716Bc7", "network": "1", "decimals": 0, "minBalance": 0}, | ||
{"address": "0xc34cbca32e355636c7f52dd8beab0af2396ebd79", "network": "137", "decimals": 0, "minBalance": 0} | ||
] | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0xC5e38233Cc0D7CFf9340e6139367aBA498EC9b18", | ||
"0x2009a752a50D3CDe486d7b5921944377B729E747", | ||
"0x7b15e6c439b27a553b65a9904ce571da6691a0fb", | ||
"0x8d2f3a76a76f055d62a931678ab16b042e7badeb", | ||
"0xEDe64a571CFe98B936271B935a955620f387E05A" | ||
], | ||
"snapshot": 13317369 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { strategy as multichainStrategy } from '../multichain'; | ||
|
||
export const author = 'lightninglu10'; | ||
export const version = '0.1.0'; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const tokens = options.tokenAddresses || []; | ||
|
||
options.strategies = tokens.map((token) => ({ | ||
"name": "erc20-with-balance", | ||
"network": token.network, | ||
"params": { | ||
"address": token.address, | ||
"decimals": token.decimals, | ||
"minBalance": token.minBalance | ||
} | ||
})); | ||
|
||
const scores: any = await multichainStrategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
); | ||
|
||
return Object.fromEntries( | ||
Object.entries(scores).map((address: any) => [ | ||
address[0], | ||
(address[1] === tokens.length) ? 1 : 0 | ||
]) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters