diff --git a/src/strategies/index.ts b/src/strategies/index.ts index f2299e9f6..0993dbfd2 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -479,8 +479,10 @@ import * as synapse from './synapse'; import * as dappcomposerGetVotingUnits from './dappcomposer-getvotingunits'; import * as erc20BalanceOfSaevo from './erc20-balance-of-saevo'; import * as apecoinStaking from './apecoin-staking'; +import * as sybil from './sybil'; const strategies = { + sybil, 'apecoin-staking': apecoinStaking, 'erc20-balance-of-saevo': erc20BalanceOfSaevo, livepeer, diff --git a/src/strategies/sybil/README.md b/src/strategies/sybil/README.md new file mode 100644 index 000000000..412328113 --- /dev/null +++ b/src/strategies/sybil/README.md @@ -0,0 +1,11 @@ +# sybil + +This strategy returns the score of the user in sybil contract. + +Here is an example of parameters: + +```json +{ + "address": "0x6b175474e89094c44da98b954eedeac495271d0f", +} +``` diff --git a/src/strategies/sybil/examples.json b/src/strategies/sybil/examples.json new file mode 100644 index 000000000..818dafc4a --- /dev/null +++ b/src/strategies/sybil/examples.json @@ -0,0 +1,18 @@ +[ + { + "name": "Sybil", + "strategy": { + "name": "sybil", + "params": { + "address": "0x613F350E9a6bb3614e1095B824eB9B203D9f4fD2" + } + }, + "network": "11155111", + "addresses": [ + "0xCbD25e6545DEf86B9A00E5205851F7332111C924", + "0x1DBd908b5a4f9b2c144FaF24221C74fb71CF33CE", + "0xaEc81EE0E733212FCE2E95B69272a1869673BFE5" + ], + "snapshot": 8259368 + } +] diff --git a/src/strategies/sybil/index.ts b/src/strategies/sybil/index.ts new file mode 100644 index 000000000..9abcf96a0 --- /dev/null +++ b/src/strategies/sybil/index.ts @@ -0,0 +1,34 @@ +import { BigNumberish } from '@ethersproject/bignumber'; +import { formatUnits } from '@ethersproject/units'; +import { Multicaller } from '../../utils'; + +export const author = 'DarkKnight3074'; +export const version = '0.1.1'; + +const abi = [ + 'function scoreSnapshots(address) view returns (uint32 score, uint32 batchNum)' +]; + +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, 'scoreSnapshots', [address]) + ); + const result: Record = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address, balance]) => [ + address, + parseFloat(formatUnits(balance, options.decimals)) + ]) + ); +} diff --git a/src/strategies/sybil/schema.json b/src/strategies/sybil/schema.json new file mode 100644 index 000000000..98d02c9d2 --- /dev/null +++ b/src/strategies/sybil/schema.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Strategy", + "definitions": { + "Strategy": { + "title": "Strategy", + "type": "object", + "properties": { + "address": { + "type": "string", + "title": "Contract address", + "examples": ["0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"], + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42 + } + }, + "required": ["address"] + } + } +}