-
Notifications
You must be signed in to change notification settings - Fork 790
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
Showing
5 changed files
with
107 additions
and
1 deletion.
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,13 @@ | ||
# staked-daomaker-bsc | ||
|
||
It returns the staked amount of DAO on BSC of the voters. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0x598CA79eee092A084B5f168c4196EdB80EA22781", | ||
"symbol": "DAO", | ||
"decimals": 18 | ||
} | ||
``` |
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,22 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "staked-daomaker-bsc", | ||
"params": { | ||
"address": "0x598CA79eee092A084B5f168c4196EdB80EA22781", | ||
"symbol": "DAO", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "56", | ||
"addresses": [ | ||
"0xa93065e0Ef01908c9bD016c1D78c0C2F7Fa7D523", | ||
"0x8a146531630850fE1d158c922bDA620BDDF12766", | ||
"0x3fF8CAc8ce2449ACe1C47FeBd8F3687D043f0C12", | ||
"0x70E828Ba093C5fad8202d7b1870809b40077C2Fd", | ||
"0xBd2d3ef0146B6b949DcA131576D3b6D33e2bD6cD" | ||
], | ||
"snapshot": 36679354 | ||
} | ||
] |
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,35 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'bonustrack'; | ||
export const version = '0.1.1'; | ||
|
||
const abi = [ | ||
'function users(address account) external view returns (uint256, uint256, uint256)' | ||
]; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const multi = new Multicaller(network, provider, abi, { blockTag }); | ||
addresses.forEach((address) => | ||
multi.call(address, options.address, 'users', [address]) | ||
); | ||
|
||
const result: Record<string, BigNumberish> = await multi.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address, data]) => [ | ||
address, | ||
parseFloat(formatUnits(data[0], options.decimals)) | ||
]) | ||
); | ||
} |
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,34 @@ | ||
{ | ||
"$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 | ||
}, | ||
"address": { | ||
"type": "string", | ||
"title": "Contract address", | ||
"examples": ["e.g. 0x598CA79eee092A084B5f168c4196EdB80EA22781"], | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
}, | ||
"decimals": { | ||
"type": "number", | ||
"title": "Decimals", | ||
"examples": ["e.g. 18"], | ||
"minimum": 0 | ||
} | ||
}, | ||
"required": ["address", "decimals"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |