diff --git a/src/strategies/index.ts b/src/strategies/index.ts index d2d8d36a7..949cf103a 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -413,6 +413,7 @@ import * as vendorV2BorrowerCollateralBalanceOf from './vendor-v2-borrower-colla import * as voltVotingPower from './volt-voting-power'; import * as xdaiStakersAndHolders from './xdai-stakers-and-holders'; import * as minimeBalanceVsSupplyWeighted from './minime-balance-vs-supply-weighted'; +import * as stakedDaomakerBsc from "./staked-daomaker-bsc" const strategies = { 'minime-balance-vs-supply-weighted': minimeBalanceVsSupplyWeighted, @@ -833,7 +834,8 @@ const strategies = { vendorV2BorrowerCollateralBalanceOf, 'volt-voting-power': voltVotingPower, 'xdai-stakers-and-holders': xdaiStakersAndHolders, - 'urbit-galaxies': urbitGalaxies + 'urbit-galaxies': urbitGalaxies, + 'staked-daomaker-bsc': stakedDaomakerBsc }; Object.keys(strategies).forEach(function (strategyName) { diff --git a/src/strategies/staked-daomaker-bsc/README.md b/src/strategies/staked-daomaker-bsc/README.md new file mode 100644 index 000000000..94c3ba3ed --- /dev/null +++ b/src/strategies/staked-daomaker-bsc/README.md @@ -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 +} +``` diff --git a/src/strategies/staked-daomaker-bsc/examples.json b/src/strategies/staked-daomaker-bsc/examples.json new file mode 100644 index 000000000..32fe7c731 --- /dev/null +++ b/src/strategies/staked-daomaker-bsc/examples.json @@ -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 + } +] diff --git a/src/strategies/staked-daomaker-bsc/index.ts b/src/strategies/staked-daomaker-bsc/index.ts new file mode 100644 index 000000000..331536dad --- /dev/null +++ b/src/strategies/staked-daomaker-bsc/index.ts @@ -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> { + 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 = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address, data]) => [ + address, + parseFloat(formatUnits(data[0], options.decimals)) + ]) + ); +} diff --git a/src/strategies/staked-daomaker-bsc/schema.json b/src/strategies/staked-daomaker-bsc/schema.json new file mode 100644 index 000000000..71f1595c5 --- /dev/null +++ b/src/strategies/staked-daomaker-bsc/schema.json @@ -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 + } + } +}