Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schemas to top strategies #1274

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/strategies/aave-governance-power/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ Allows to get Voting power or Proposition power from an Aave GovernanceStrategy
| 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 | | |
| | | | | |

## 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 |
| decimals | number | The decimals of the governance token |
| symbol | string | The symbol of the governance token |
2 changes: 1 addition & 1 deletion src/strategies/aave-governance-power/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"params": {
"governanceStrategy": "0xb7e383ef9b1e9189fc0f71fb30af8aa14377429e",
"powerType": "vote",
"symbol": "Voting Power",
"symbol": "ABC",
"decimals": 18
}
},
Expand Down
22 changes: 2 additions & 20 deletions src/strategies/aave-governance-power/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,8 @@ export const version = '0.1.0';
*/

const abi = [
{
inputs: [
{ internalType: 'address', name: 'user', type: 'address' },
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }
],
name: 'getPropositionPowerAt',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
},
{
inputs: [
{ internalType: 'address', name: 'user', type: 'address' },
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }
],
name: 'getVotingPowerAt',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
}
'function getPropositionPowerAt(address user, uint256 blockNumber) view returns (uint256)',
'function getVotingPowerAt(address user, uint256 blockNumber) view returns (uint256)'
];

const powerTypesToMethod = {
Expand Down
38 changes: 38 additions & 0 deletions src/strategies/aave-governance-power/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$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. ETH"],
"maxLength": 16
},
"governanceStrategy": {
"type": "string",
"title": "governanceStrategy",
"examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"decimals": {
"type": "integer",
"title": "Decimals",
"examples": ["e.g. 18"]
},
"powerType": {
"type": "string",
"title": "powerType",
"examples": ["e.g. vote"]
}
},
"required": ["governanceStrategy", "powerType"],
"additionalProperties": false
}
}
}
97 changes: 30 additions & 67 deletions src/strategies/contract-call/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,43 @@

Allows any contract method to be used to calculate voter scores.

## Params

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| address | `string` | `undefined` | The address of the contract |
| symbol (optional) | `string` | `undefined` | The symbol of the token |
| decimals | `number` | `undefined` | The decimals of the output |
| methodABI | `object` | `undefined` | The ABI of the method to call |
| output (optional) | `string` | `undefined` | If the method return an array or object, the key to use as output |

## Examples

Can be used instead of the erc20-balance-of strategy, the space config will look like this:

```JSON
{
"strategies": [
["contract-call", {
// token address
"address": "0x6887DF2f4296e8B772cb19479472A16E836dB9e0",
// token decimals
"decimals": 18,
// token symbol
"symbol": "DAI",
// ABI for balanceOf method
"methodABI": {
"constant": true,
"inputs": [{
"internalType": "address",
"name": "account",
"type": "address"
}],
"name": "balanceOf",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
"address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
"symbol": "Cake",
"decimals": 18,
"methodABI": {
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
}],
]
}
```

You can call methods with multiple inputs in any contract:

```JSON
{
"strategies": [
["contract-call", {
// contract address
"address": "0x6887DF2f4296e8B772cb19479472A16E836dB9e0",
// output decimals
"decimals": 18,
// strategy symbol
"symbol": "mySCORE",
// arguments are passed to the method; "%{address}" is replaced with the voter's address; default value ["%{address}"]
"args": ["0x6887DF2f4296e8B772cb19479472A16E836dB9e0", "%{address}"],
// method ABI, output type should be uint256
"methodABI": {
"constant": true,
"inputs": [{
"internalType": "address",
"name": "_someAddress",
"type": "address"
}, {
"internalType": "address",
"name": "_voterAddress",
"type": "address"
}],
"name": "totalScoresFor",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"payable": false,
"stateMutability": "view",
"type": "function"
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
}],
]
],
"stateMutability": "view",
"type": "function"
}
}
```
8 changes: 6 additions & 2 deletions src/strategies/contract-call/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
}
},
"network": "56",
"addresses": ["0x009cF7bC57584b7998236eff51b98A168DceA9B0"],
"snapshot": 13839867
"snapshot": 31246550,
"addresses": [
"0x009cF7bC57584b7998236eff51b98A168DceA9B0",
"0x45c54210128a065de780C4B0Df3d16664f7f859e",
"0x0eD7e52944161450477ee417DE9Cd3a859b14fD0"
]
}
]
101 changes: 101 additions & 0 deletions src/strategies/contract-call/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$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. ETH"],
"maxLength": 16
},
"address": {
"type": "string",
"title": "Contract address",
"examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"decimals": {
"type": "integer",
"title": "Decimals",
"examples": ["e.g. 18"]
},
"methodABI": {
"type": "object",
"title": "Method ABI",
"properties": {
"name": {
"type": "string",
"title": "Name",
"examples": ["e.g. balanceOf"]
},
"inputs": {
"type": "array",
"title": "Inputs",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name",
"examples": ["e.g. account"]
},
"type": {
"type": "string",
"title": "Type",
"examples": ["e.g. address"]
},
"internalType": {
"type": "string",
"title": "Internal type",
"examples": ["e.g. address"]
}
},
"required": ["name", "type"],
"additionalProperties": false
}
},
"outputs": {
"type": "array",
"title": "Outputs",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name",
"examples": ["e.g. balance"]
},
"type": {
"type": "string",
"title": "Type",
"examples": ["e.g. uint256"]
},
"internalType": {
"type": "string",
"title": "Internal type",
"examples": ["e.g. uint256"]
}
},
"required": ["name", "type"],
"additionalProperties": false
}
}
}
},
"output": {
"type": "string",
"title": "Output (Optional)",
"examples": ["e.g. balance"]
}
},
"required": ["address", "methodABI"],
"additionalProperties": false
}
}
}
2 changes: 1 addition & 1 deletion src/strategies/delegation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Here is an example of parameters:
]
}

```
```
58 changes: 58 additions & 0 deletions src/strategies/delegation/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$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. UNI"
],
"maxLength": 16
},
"strategies": {
"type": "array",
"title": "Strategies",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"params": {
"type": "object"
},
"network": {
"type": "string",
"title": "Network (optional)"
}
},
"required": [
"name",
"params"
]
},
"minItems": 1,
"maxItems": 8,
"uniqueItems": true
},
"delegationSpace": {
"type": "string",
"title": "Delegation space (optional)",
"examples": [
"e.g. poh.eth"
]
}
},
"required": [
"strategies"
],
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"symbol": "POHD",
"address": "0x1dAD862095d40d43c2109370121cf087632874dB",
"decimals": 0,
"delegationSpace": "poh.eth"
"delegationSpace": "poh.eth",
"delegationNetwork": "1"
}
},
"network": "1",
Expand Down
Loading