forked from snapshot-labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'snapshot-labs:master' into master
- Loading branch information
Showing
43 changed files
with
1,156 additions
and
278 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 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
allow: | ||
# Allow updates for snapshot.js only | ||
- dependency-name: "@snapshot-labs/snapshot.js" |
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
# Contract call strategy | ||
# aave-governance-power strategy | ||
|
||
Allows to get Voting power or Proposition power from an Aave GovernanceStrategy contract. | ||
|
||
## Strategy Parameters | ||
## Params | ||
|
||
| Param | Type | Description | | | | ||
| ------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------- | --- | --- | | ||
| governanceStrategy | string | The Ethereum address of the GovernanceStrategy contract to measure voting or proposition power from an address at a block. | | | | ||
| powerType | string | Use `vote` for Voting Power or `proposition` for Proposition Power | | | | ||
| | | | | | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| governanceStrategy | string | The Ethereum address of the GovernanceStrategy contract to measure voting or proposition power from an address at a block. | | ||
| powerType | string | Use `vote` for Voting Power or `proposition` for Proposition Power | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/Strategy", | ||
"definitions": { | ||
"Strategy": { | ||
"title": "Strategy", | ||
"type": "object", | ||
"properties": { | ||
"symbol": { | ||
"type": "string", | ||
"title": "Symbol", | ||
"examples": ["e.g. DOODLE"], | ||
"maxLength": 16 | ||
}, | ||
"governanceStrategy": { | ||
"type": "string", | ||
"title": "Contract address", | ||
"examples": ["e.g. 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"], | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
}, | ||
"powerType": { | ||
"type": "string", | ||
"title": "Power type", | ||
"enum": ["vote", "proposition"] | ||
}, | ||
"decimals": { | ||
"type": "integer", | ||
"title": "Decimals", | ||
"examples": ["e.g. 18"], | ||
"minimum": 0, | ||
"maximum": 18 | ||
} | ||
}, | ||
"required": ["governanceStrategy", "powerType", "decimals"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
# erc20-balance-of-top-holders | ||
|
||
Strategy, that accept votes only from top N token holders | ||
|
||
Subgraph should be compatible with [OpenZeppelin ERC20 Subgraph](https://github.com/OpenZeppelin/openzeppelin-subgraphs) | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0x8494Aee22e0DB34daA1e8D6829d85710357be9F7", | ||
"symbol": "HANDZ", | ||
"decimals": 18, | ||
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/kostyamospan/handz-token", | ||
"topHolders": 5 | ||
} | ||
``` |
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,30 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "erc20-balance-of-top-holders", | ||
"params": { | ||
"address": "0x8494Aee22e0DB34daA1e8D6829d85710357be9F7", | ||
"symbol": "HANDZ", | ||
"decimals": 18, | ||
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/kostyamospan/handz-token", | ||
"topHolders": 5 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0xD87dec8eE5d941234d85a9d2636D077fE03B0660", | ||
"0x54B9ca09248C49e9ed0968bfD0AA0bd13E85992A", | ||
"0x254c8A6225CE32903D2657D0945701ACD6e42188", | ||
"0xF59Dd6525529F77cF90Ec9A8205d52874af7a425", | ||
"0x0a0A1669A7E3f16b3010dD78F53D3E22Dcf4b739", | ||
"0x5b941eA7387190Ba6a0bF4B766c1F3eB0Ab30A25", | ||
"0xc0D57b31F33Ce4f6627d353Ac51461fB7cDC1519", | ||
"0xF5De2507726A312aD6f806A9972Ed438344022b2", | ||
"0x33b5752C03495014A130f8f4A235f6280C58f266", | ||
"0x6323b71f37a07642F8055E9847B58Ffc9FA44243", | ||
"0xf5F730146D177Cf7Dd28AA39F81359DaE51D4379" | ||
], | ||
"snapshot": 18020926 | ||
} | ||
] |
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,73 @@ | ||
import { subgraphRequest } from '../../utils'; | ||
import { getAddress } from '@ethersproject/address'; | ||
|
||
export const author = 'RedDuck-Software'; | ||
export const version = '0.0.1'; | ||
|
||
async function getTopHoldersBalance( | ||
url, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const topHoldersAmount = +options.topHolders || 0; | ||
|
||
const query = { | ||
erc20Balances: { | ||
__args: { | ||
where: { | ||
account_not: null, | ||
contract: options.address | ||
}, | ||
orderBy: 'valueExact', | ||
orderDirection: 'desc', | ||
first: topHoldersAmount | ||
}, | ||
value: true, | ||
contract: true, | ||
account: { | ||
id: true | ||
} | ||
} | ||
}; | ||
|
||
if (snapshot !== 'latest') { | ||
// @ts-ignore | ||
query.erc20Balances.__args.block = { number: snapshot }; | ||
} | ||
|
||
const topHolders: Record<string, number> = {}; | ||
|
||
const result = await subgraphRequest(url, query); | ||
|
||
if (result && result.erc20Balances) { | ||
result.erc20Balances.forEach((tokenBalance) => { | ||
const address = getAddress(tokenBalance.account.id); | ||
const balance = parseFloat(tokenBalance.value); | ||
topHolders[address] = balance; | ||
}); | ||
} | ||
|
||
return topHolders; | ||
} | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const topHoldersBalancesScores = await getTopHoldersBalance( | ||
options.subgraphUrl, | ||
options, | ||
snapshot | ||
); | ||
|
||
return Object.fromEntries( | ||
addresses.map((address) => [ | ||
address, | ||
topHoldersBalancesScores[address] ? topHoldersBalancesScores[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# friend-tech | ||
|
||
This strategy allocates voting power according to the number of keys (or shares) a voter possesses on friend.tech for a particular user. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0xe12a2f60b400e6c6971d5602df454e5da63edd78", | ||
"symbol": "KEYS" | ||
} | ||
``` |
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": "friend-tech", | ||
"params": { | ||
"address": "0xe12A2f60B400E6c6971D5602DF454E5dA63eDD78", | ||
"symbol": "KEYS" | ||
} | ||
}, | ||
"network": "8453", | ||
"addresses": [ | ||
"0x81a9a7979f5EB27588b5AB9448398ad321Dba90C", | ||
"0x3B7576DF0Ef2d6c1656245aE15Ad52DCf34FD04a", | ||
"0x7C2FDC7de9F536560E47105257a57C8C8dF79372" | ||
], | ||
"snapshot": 2933820 | ||
} | ||
] |
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,33 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'bonustrack'; | ||
export const version = '0.1.0'; | ||
|
||
const abi = ['function sharesBalance(address,address) view returns (uint256)']; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
const contract = '0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4'; | ||
|
||
const multi = new Multicaller(network, provider, abi, { blockTag }); | ||
addresses.forEach((address) => | ||
multi.call(address, contract, 'sharesBalance', [options.address, address]) | ||
); | ||
const result: Record<string, BigNumberish> = await multi.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address, balance]) => [ | ||
address, | ||
parseFloat(formatUnits(balance, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/Strategy", | ||
"definitions": { | ||
"Strategy": { | ||
"title": "Strategy", | ||
"type": "object", | ||
"properties": { | ||
"address": { | ||
"type": "string", | ||
"title": "User address", | ||
"examples": ["e.g. 0xe12a2f60b400e6c6971d5602df454e5da63edd78"], | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
}, | ||
"symbol": { | ||
"type": "string", | ||
"title": "Symbol", | ||
"examples": ["e.g. KEYS"], | ||
"maxLength": 16 | ||
} | ||
}, | ||
"required": ["address"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
Oops, something went wrong.