Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
Open
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
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions src/strategies/sybil/README.md
Original file line number Diff line number Diff line change
@@ -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",
}
```
18 changes: 18 additions & 0 deletions src/strategies/sybil/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"name": "Sybil",
"strategy": {
"name": "sybil",
"params": {
"address": "0x613F350E9a6bb3614e1095B824eB9B203D9f4fD2"
}
},
"network": "11155111",
"addresses": [
"0xCbD25e6545DEf86B9A00E5205851F7332111C924",
"0x1DBd908b5a4f9b2c144FaF24221C74fb71CF33CE",
"0xaEc81EE0E733212FCE2E95B69272a1869673BFE5"
],
"snapshot": 8259368
}
]
34 changes: 34 additions & 0 deletions src/strategies/sybil/index.ts
Original file line number Diff line number Diff line change
@@ -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<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, 'scoreSnapshots', [address])
);
const result: Record<string, BigNumberish> = await multi.execute();

return Object.fromEntries(
Object.entries(result).map(([address, balance]) => [
address,
parseFloat(formatUnits(balance, options.decimals))
])
);
}
Comment on lines +12 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @DarkKnight3074 You can actually use contract-call strategy on your space directly instead of a new strategy, you tried?

21 changes: 21 additions & 0 deletions src/strategies/sybil/schema.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
}