Skip to content

Commit

Permalink
[ocean-dao-brightid] Add Ocean DAO BrightID strategy (snapshot-labs#224)
Browse files Browse the repository at this point in the history
* Add ocean-marketplace-brightid strategy

* Remove square root

* Add `brightIdNetwork` param

* Rename strategy to `ocean-dao-brightid`

* Add `README.md`

* Rename folder

* Update registry address & add new param

* Use `notVerifiedMultiplier` param

* Set allowed strategies and limit the number

* Update comments

* Remove `brightIdNetwork` param

* Set the `blockTag` to `snapshot`

* Update src/strategies/ocean-dao-brightid/index.ts

* Update block number

Co-authored-by: Chaitanya <[email protected]>
  • Loading branch information
trizin and ChaituVR authored Dec 14, 2021
1 parent ac15ef8 commit 1bd858f
Showing 4 changed files with 289 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
@@ -208,6 +208,7 @@ import * as snetStakers from './snet-stakers';
import * as snetLiquidityProviders from './snet-liquidity-providers';
import * as minMaxMcnFarm from './minmax-mcn-farm';
import * as unstackedToadzAndStackedToadzStakers from './unstackedtoadz-and-stackedtoadz-stakers';
import * as oceanDAOBrightID from './ocean-dao-brightid';
import * as saddleFinance from './saddle-finance';
import * as lydiaGovVault from './lydia-gov-vault';
import * as xkawaFarm from './xkawa-farm';
@@ -421,6 +422,7 @@ const strategies = {
'snet-liquidity-providers': snetLiquidityProviders,
'minmax-mcn-farm': minMaxMcnFarm,
'unstackedtoadz-and-stackedtoadz-stakers': unstackedToadzAndStackedToadzStakers,
'ocean-dao-brightid': oceanDAOBrightID,
'saddle-finance': saddleFinance,
'lydia-gov-vault': lydiaGovVault,
'xkawa-farm': xkawaFarm,
92 changes: 92 additions & 0 deletions src/strategies/ocean-dao-brightid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Ocean DAO BrightID Snapshot strategy

`version 0.1`

This strategy sums the scores of given multiple strategies for each voter. If the voter is verified on the BrightId registry contract, the score of the voter is multiplied by a factor of `brightIdMultiplier` parameter.

Example parameters:

```json
{
"brightIdMultiplier": 5,
"brightIdNetwork": "4",
"registry": "0xbD45cf7C9f8eE04409C31D0ef939D4b0926263Ae",
"symbol": "OCEAN",
"strategies": [
{
"name": "erc20-balance-of",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "ocean-marketplace",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "sushiswap",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "uniswap",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "contract-call",
"params": {
"address": "0x9712Bb50DC6Efb8a3d7D12cEA500a50967d2d471",
"args": [
"%{address}",
"0xCDfF066eDf8a770E9b6A7aE12F7CFD3DbA0011B5",
"0x967da4048cD07aB37855c090aAF366e4ce1b9F48"
],
"decimals": 18,
"symbol": "OCEAN",
"methodABI": {
"inputs": [
{
"internalType": "address",
"name": "provider",
"type": "address"
},
{
"internalType": "address",
"name": "poolToken",
"type": "address"
},
{
"internalType": "address",
"name": "reserveToken",
"type": "address"
}
],
"name": "totalProviderAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
}
}
]
}
```
124 changes: 124 additions & 0 deletions src/strategies/ocean-dao-brightid/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[
{
"name": "Ocean Marketplace BrightID Stategy",
"strategy": {
"name": "ocean-dao-brightid",
"params": {
"brightIdMultiplier": 5,
"notVerifiedMultiplier": 1,
"registry": "0xc37F8341Ac6e4a94538302bCd4d49Cf0852D30C0",
"symbol": "OCEAN",
"strategies": [
{
"name": "erc20-balance-of",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "ocean-marketplace",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "sushiswap",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "uniswap",
"params": {
"symbol": "OCEAN",
"address": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
"decimals": 18
}
},
{
"name": "contract-call",
"params": {
"address": "0x9712Bb50DC6Efb8a3d7D12cEA500a50967d2d471",
"args": [
"%{address}",
"0xCDfF066eDf8a770E9b6A7aE12F7CFD3DbA0011B5",
"0x967da4048cD07aB37855c090aAF366e4ce1b9F48"
],
"decimals": 18,
"symbol": "OCEAN",
"methodABI": {
"inputs": [
{
"internalType": "address",
"name": "provider",
"type": "address"
},
{
"internalType": "address",
"name": "poolToken",
"type": "address"
},
{
"internalType": "address",
"name": "reserveToken",
"type": "address"
}
],
"name": "totalProviderAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
}
}
]
}
},
"network": "1",
"addresses": [
"0xa478c2975ab1ea89e8196811f51a7b7ade33eb11",
"0xeF8305E140ac520225DAf050e2f71d5fBcC543e7",
"0x1E1A51E25f2816335cA436D65e9Af7694BE232ad",
"0x1F717Ce8ff07597ee7c408b5623dF40AaAf1787C",
"0x1c7a9275F2BD5a260A9c31069F77d53473b8ae2e",
"0x1d5E65a087eBc3d03a294412E46CE5D6882969f4",
"0x1f254336E5c46639A851b9CfC165697150a6c327",
"0x2ec3F80BeDA63Ede96BA20375032CDD3aAfb3030",
"0x4AcBcA6BE2f8D2540bBF4CA77E45dA0A4a095Fa2",
"0x4F3D348a6D09837Ae7961B1E0cEe2cc118cec777",
"0x6D7f23A509E212Ba7773EC1b2505d1A134f54fbe",
"0x07a1f6fc89223c5ebD4e4ddaE89Ac97629856A0f",
"0x8d5F05270da470e015b67Ab5042BDbE2D2FEFB48",
"0x8d07D225a769b7Af3A923481E1FdF49180e6A265",
"0x8f60501dE5b9b01F9EAf1214dbE1924aA97F7fd0",
"0x9B8e8dD9151260c21CB6D7cc59067cd8DF306D58",
"0x17ea92D6FfbAA1c7F6B117c1E9D0c88ABdc8b84C",
"0x38C0039247A31F3939baE65e953612125cB88268",
"0xf25B7b8dC2B264Be6c3410e2CAE339c041B854C2",
"0x655eFe6Eb2021b8CEfE22794d90293aeC37bb325",
"0xCe7BE31f48205C48A91A84E777a66252Bba87F0b",
"0x788550D00579F66c06ce209D14056C8F2c0A8188",
"0x18F93FA526e598769fd909F1D2C82315219d49Ed",
"0xA321025df54C18CEeFdE118c0671735390aCB318",
"0x8a4C36a99b0418BF95A155160C31A267EBCA8754",
"0x5e22b34F2708EA7e25918B8FCF816F9CfF27a331",
"0x12BD31628075C20919BA838b89F414241b8c4869",
"0xf88bD9c3F81f7148E4076bBB8b2e2B0951A8cE38",
"0xAAB9EaBa1AA2653c1Dda9846334700b9F5e14E44",
"0xB9b14C4d0cbc18FC5f54701D578e85968cf19FD5"
],
"snapshot": 13803684
}
]
71 changes: 71 additions & 0 deletions src/strategies/ocean-dao-brightid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { getScoresDirect, multicall } from '../../utils';

export const author = 'trizin';
export const version = '0.1.0';

const abi = [
'function isVerifiedUser(address _user) external view returns (bool)'
];

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
) {
const ALLOWED_STRATEGIES = [
'erc20-balance-of',
'ocean-marketplace',
'sushiswap',
'uniswap',
'contract-call'
];
if (
options.strategies.length > 5 ||
options.strategies.some((x) => !ALLOWED_STRATEGIES.includes(x.name))
)
return [];
const response = await multicall(
network,
provider,
abi,
addresses.map((address: any) => [
options.registry,
'isVerifiedUser',
[address]
]),
{ blockTag: snapshot }
);
let scores = await getScoresDirect(
space,
options.strategies,
network,
provider,
addresses,
snapshot
);
// [{ address: '0x...', score: 0.5 },{ address: '0x...', score: 0.5 }]
// sum scores for each address and return
scores = scores.reduce((finalScores: any, score: any) => {
for (const [address, value] of Object.entries(score)) {
if (!finalScores[address]) {
finalScores[address] = 0;
}
finalScores[address] += value;
}
return finalScores;
}, {});
// { address: '0x...55', score: 1.0 }

return Object.fromEntries(
addresses.map((address, index) => {
let addressScore = scores[address];
addressScore *= response[index][0]
? options.brightIdMultiplier // brightId multiplier
: options.notVerifiedMultiplier; // not verified multiplier
return [address, addressScore];
})
);
}

0 comments on commit 1bd858f

Please sign in to comment.