forked from LayerZero-Labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ocean-dao-brightid] Add Ocean DAO BrightID strategy (snapshot-labs#224)
* 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
Showing
4 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
}) | ||
); | ||
} |