Skip to content

Commit

Permalink
added WLFI voting strategy for untransferable tokens (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreycaplan3 authored Oct 13, 2024
1 parent 2eb039b commit 50d1129
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ import * as candyNftStaking from './candy-nft-staking';
import * as pom from './pom';
import * as superboring from './superboring';
import * as erableGovernanceV1 from './erable-governance-v1';
import * as worldLibertyFinancial from './world-liberty-financial-erc20-balance-of-votes';
import * as snxMultichain from './snx-multichain';

const strategies = {
Expand Down Expand Up @@ -922,6 +923,7 @@ const strategies = {
pom,
superboring,
'erable-governance-v1': erableGovernanceV1,
'world-liberty-financial-erc20-balance-of-votes': worldLibertyFinancial,
'snx-multichain': snxMultichain
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# world-liberty-financial-erc20-balance-of-votes

This query returns the balances of the voters for the WLFI ERC20 token while transfers are disabled.

Here is an example of parameters:

```json
{
"address": "0xdA5e1988097297dCdc1f90D4dFE7909e847CBeF6",
"symbol": "WLFI",
"decimals": 18
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "Example query",
"strategy": {
"name": "world-liberty-financial-erc20-balance-of-votes",
"params": {
"address": "0xdA5e1988097297dCdc1f90D4dFE7909e847CBeF6",
"symbol": "WLFI",
"decimals": 18
}
},
"network": "1",
"addresses": [
"0x1246E490308db61DCa45ead613f47430De3830ad",
"0xEe7f7f53F0D0c8c56A38e97c5a58E4d321A174dC",
"0xF32e3596f555546ACc4aD6Ef67e1ABF36b134748"
],
"snapshot": 20942069
}
]
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 = 'coreycaplan3';
export const version = '0.1.0';

const abi = [
'function balanceOfVotes(address account) external view returns (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, 'balanceOfVotes', [address])
);
const result: Record<string, BigNumberish> = await multi.execute();

return Object.fromEntries(
Object.entries(result).map(([address, balance]) => [
address,
parseFloat(formatUnits(balance, options.decimals))
])
);
}
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. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],
"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
}
}
}

0 comments on commit 50d1129

Please sign in to comment.