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.
- Loading branch information
1 parent
29e27c8
commit d2e78d3
Showing
13 changed files
with
172 additions
and
94 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
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,11 @@ | ||
# Coordinape | ||
|
||
Use Coordinape circle epoch tokens as voting power. | ||
|
||
Here is an example of parameters: | ||
```json | ||
{ | ||
"symbol": "CIRCLE", | ||
"circle": "92" | ||
} | ||
``` |
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,19 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "coordinape", | ||
"params": { | ||
"symbol": "CIRCLE", | ||
"circle": "92" | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x823b92d6a4b2AED4b15675c7917c9f922ea8ADAD", | ||
"0xd337fccaec6ea113baacca3a41eb8766706a0706", | ||
"0xeF8305E140ac520225DAf050e2f71d5fBcC543e7" | ||
], | ||
"snapshot": 13219000 | ||
} | ||
] |
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,36 @@ | ||
import fetch from 'cross-fetch'; | ||
import { getAddress } from '@ethersproject/address'; | ||
|
||
export const author = 'bonustrack'; | ||
export const version = '0.1.0'; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const url = `https://coordinape.me/api/${options.circle}/token-gifts?latest_epoch=1&snapshot=${snapshot}`; | ||
const res = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
const gifts = await res.json(); | ||
const scores = {}; | ||
gifts.forEach(gift => { | ||
const address = getAddress(gift.recipient_address); | ||
if (!scores[address]) scores[address] = 0; | ||
scores[address] += gift.tokens; | ||
}); | ||
return Object.fromEntries( | ||
addresses.map(address => [ | ||
address, | ||
scores[getAddress(address)] || 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
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
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
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
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
Oops, something went wrong.