Skip to content

Commit

Permalink
[has-rock] Rock NFT voting strategy (snapshot-labs#46)
Browse files Browse the repository at this point in the history
* Rock Voting Strategy

* Rock Voting Strategy

* Update src/strategies/has-rock/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/has-rock/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/has-rock/index.ts

Co-authored-by: Chaitanya <[email protected]>

Co-authored-by: Chaitanya <[email protected]>
  • Loading branch information
0xMeir and ChaituVR authored Aug 30, 2021
1 parent 7f374be commit 503b2f4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/strategies/has-rock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# has-rocks

This is a strategy for addresses with rocks.
17 changes: 17 additions & 0 deletions src/strategies/has-rock/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "Example query",
"strategy": {
"name": "has-rock",
"params": {
"address": "0x37504AE0282f5f334ED29b4548646f887977b7cC",
"symbol": "ROCK"
}
},
"network": "1",
"addresses": [
"0x66C25a700F9c762891b4d6fbf5aF9Dc2eb04266A"
],
"snapshot": 13118882
}
]
50 changes: 50 additions & 0 deletions src/strategies/has-rock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { multicall } from '../../utils';

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

const abi = [
'function rocks(uint256) view returns (address owner, bool currentlyForSale, uint256 price, uint256 timesSold)'
];

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
) {
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';

let calls = [] as any;
for (var i=0; i< 100; i++){
calls.push([
options.address,
'rocks',
[i]
])
}

const response = await multicall(
network,
provider,
abi,
calls,
{ blockTag }
);

let result = {} as any;

addresses.forEach((address, x)=> {
let addressRocks = 0;
response.forEach((rockObject, i) => {
if (rockObject.owner == address){
addressRocks++;
}
})
result[address] = addressRocks
})

return result;
}
4 changes: 3 additions & 1 deletion src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ import * as mcnFarm from './mcn-farm';
import * as snowswap from './snowswap';
import * as meebitsdao from './meebitsdao';
import * as crucibleERC20BalanceOf from './crucible-erc20-balance-of';
import * as hasrock from './has-rock';

const strategies = {
'anti-whale': antiWhale,
Expand Down Expand Up @@ -275,7 +276,8 @@ const strategies = {
'mcn-farm': mcnFarm,
snowswap,
meebitsdao,
'crucible-erc20-balance-of': crucibleERC20BalanceOf
'crucible-erc20-balance-of': crucibleERC20BalanceOf,
'has-rock':hasrock
};

Object.keys(strategies).forEach(function (strategyName) {
Expand Down

0 comments on commit 503b2f4

Please sign in to comment.