forked from snapshot-labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Loot Character Guild Strategy (snapshot-labs#84)
- Loading branch information
1 parent
ce7ab67
commit 9cee15f
Showing
3 changed files
with
206 additions
and
1 deletion.
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,144 @@ | ||
[ | ||
{ | ||
"name": "Loot Character Guild ", | ||
"strategy": { | ||
"name": "loot-character-guilds", | ||
"params": { | ||
"lootAddress": "0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7", | ||
"lootCharacterGuildsAddress": "0xBbb55b52d2186C4dd99cDba7AF483459E517BE3d", | ||
"guildId": 5 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x08D816526BdC9d077DD685Bd9FA49F58A5Ab8e48", | ||
"0xF4b0498e71485717f6f9b6117672C19A0dbA5100", | ||
"0x8e246c8c37c82D3F89726773e58b43BAa8614214", | ||
"0x9Ed0318B4d343390B47C92FE46E35f28D2edcffc", | ||
"0x808700A1eDFEDa468d34d08cA8a0397bad2298d9", | ||
"0x87E386cEdb82CF8F080b3505ADaE1eF699e65057", | ||
"0x628061dE62c327A8be104f92746c56645995eAe7", | ||
"0x6c0D14C67CCa5E944f2eB168EC4196e2c4658068", | ||
"0xc0Bbc17910BafCAB69F6bEF8574C7625134df13f", | ||
"0xc887fAdC6baAa8cD234d9104A65b37265522b024", | ||
"0x7896062Cbee5B512ea2b5A6182d1c89438aaeE5f", | ||
"0x2d639D4A4D471FB54dA6d88dEf2d263acF3108A8", | ||
"0x06Ac1F9f86520225b73EFCe4982c9d9505753251", | ||
"0x38Cb027d65AaF2d3f401Ff9bD0599AFe86F1b627", | ||
"0x7CcaCab19ee2B7EC643Ef2d436c235A5c1E76Fa9", | ||
"0xF090DC8364cdA35c8E911336026BCe394539c9D3", | ||
"0xA153dcFE203509CF292634Ac3BcaF5Ca1D4CC517", | ||
"0x92572aae1c9C4BA92011a6A56579c79dBb272Cd8", | ||
"0x9c88e9bd9daE5Cc0a7A2034DB653D668a3b0b3F9", | ||
"0xf27822E9AB6DA97481E6E1533a2314eDC44F41E4", | ||
"0x84AB05F09B5ad3a1de6941FBf29BdF77CC7E2100", | ||
"0x8A7f7C5b556B1298a74c0e89df46Eba117A2F6c1", | ||
"0x80778937998a7b9D80Ae116918242065eD1a1d22", | ||
"0xB62E9f2e6babC43F2e0E38FcF951Dc546706B191", | ||
"0x21316179A55c963171f55A154c11Ce7314d9DAa6", | ||
"0x47e5C9e909133DbB1d705286842d2DE1f89536A3", | ||
"0x27824f56bb0e722bDe0a6B1b28dFb2FE9D4285ca", | ||
"0xff563d18B082aE0EE76bce29bCbc7FD86Dc0Eb9A", | ||
"0xE0BD70803045a9D877D39bb3Cd44a5d59a378663", | ||
"0x06B3564ef920FD55f19f95EB7114EAb3eE83A192", | ||
"0x7e9045bE45bAD250d06416a877f00320971c97E0", | ||
"0xba818e7F6b208F5A4f7Cf282A9248D221144E4e5", | ||
"0x96774B92C7D0CC97a83AF06Ce68195Fa68590270", | ||
"0x360cbbdd4e42683Ba40Ee6A9BDAb3E4Dd6f27087", | ||
"0x4b2AcB5A7FCfeE322Ce3Cd8344Ea466954Fde7dB", | ||
"0x7250982aee4667254a47916Dc4523537EE59fe8B", | ||
"0xbbd75dB64A9674D35DAD240811bA0880AD0E106F", | ||
"0xd6CB70a88bB0D8fB1be377bD3E48e603528AdB54", | ||
"0xC6c41119Af1e0840357245c66baAf0e21B694D4d", | ||
"0x84Ead439d77BA323C40b615283AED434180df2D0", | ||
"0x521CcFf42a8277b6b5D29c0AcbEC2Cdd3Af9C332", | ||
"0x6F1B12a415E035eEbDc8559130eA8bdb96ADd48c", | ||
"0x8be902e0873a2a8bf8a4218e75c7e2b4419d0d04", | ||
"0x23324ed44904260fE555B18E5Ba95C6030B9227d", | ||
"0x1668c9725e27Bf5943bBD43886E1Fb5AFe75c46C", | ||
"0xfB843f8c4992EfDb6b42349C35f025ca55742D33", | ||
"0x5793b2C0B3bf7C9cf9e73C24EE9F7230bE057d08", | ||
"0x4cFde2011629A443A77F6a9137186d6B36C39938", | ||
"0x7e023390133398fEA29AB8Fa950C3D3e36939E08", | ||
"0x1e341Aa44c293d95d13d778492D417D1BE4E63D5", | ||
"0x512fce9B07Ce64590849115EE6B32fd40eC0f5F3", | ||
"0x957291Eae3d53b5A7c0A6BF2C0F08de5d87b14f6", | ||
"0xA351a4FffCeed60b6d4351e1B20C55E3A6fB5503", | ||
"0x175554B30E4dc15F0875A1ee00F137eac9461a46", | ||
"0x8404EFA98a4e129855c200FC4e90c257078d9eD3", | ||
"0xB670768c72510493AC1Fd2B9AfF66DE1F669E05E", | ||
"0xaFbc3F98EEDB5f9A25a4AB2232d1346612efE77C", | ||
"0x089FCE8bE711CABc806d69B1d0d5aebd52A06455", | ||
"0xDBfb45ac11CE31757E09e96e0820831C6cff37af", | ||
"0x08F78C6228879B2839fcF84eD3c22E9a30A5A2D3", | ||
"0x832668b0fc7D007f5C40375457ce147D6235cA9D", | ||
"0x380E5b655d459A0cFa6fa2DFBbE586bf40DcFd7F", | ||
"0xF296178d553C8Ec21A2fBD2c5dDa8CA9ac905A00", | ||
"0xA494876207Ae80D8669Dd347Fe11Fadae31c48E7", | ||
"0x1ec9503BbdaD721EF3aD485b4B14Ce0671Dc9925", | ||
"0xBF8AfA76BcC2f7Fee2F3b358571F426a698E5edD", | ||
"0x87D9C2D9990A9f3A18F1377Ff20d9945F9eB3792", | ||
"0x8e3e4f8884C093cc2df3BC4D49b3Ab3d558b4e13", | ||
"0x32Ce58aa25161e9D53010cE33295A05037F6e69c", | ||
"0x003F35595dce3187B4Fff2B5A2c4303f7158208a", | ||
"0x74B78e98093F5B522A7eBDAc3B994641cA7c2b20", | ||
"0x5069304255FF9b5f0d57b59F79A8865b4e622279", | ||
"0x392027fDc620d397cA27F0c1C3dCB592F27A4dc3", | ||
"0x5090c4Fead5Be112b643BC75d61bF42339675448", | ||
"0xf5f0B993d69e3E6480f7F5c2531154eCf60278cF", | ||
"0xD9Ec0058d49254E8E7e8f021A056865C3a0A2C0b", | ||
"0xeB369F468d91E575fD30712a0ABfcF99FdF75e30", | ||
"0x14A03CA8740A0044E63d3Bb0432540d9509473d1", | ||
"0xc6025ED82cf2f3d87595195Ed6a1ae1a5a94Ecee", | ||
"0xd6464a34847188540EB0860d660866F732C38744", | ||
"0xa1122D9fbe7f60fE8e328FE5Bb1534D72fBD3B59", | ||
"0x2Afc91a1c9a94dCDabc5dDe6A7ab810668C49583", | ||
"0xF73FE15cFB88ea3C7f301F16adE3c02564ACa407", | ||
"0x4654F56a64301b9b582F843F97332D96Ead11FF8", | ||
"0x3aDFA4AB755E96b84cC7a00F8f375D7A4A203E8a", | ||
"0x98733a6517cDb5da94a2115d5AddD1C386f7Ef8f", | ||
"0xD5520354A956A736F67c3F03c7755Ff0486D9F0e", | ||
"0x78AB747D6675AB1dfeE31D0BfB6862124565AefC", | ||
"0xB0623C91c65621df716aB8aFE5f66656B21A9108", | ||
"0x8b7a5B22175614EE194E9e02e9fE0A1B5414C75E", | ||
"0x649f69CCd077Da03dFb11f4b1daAb4B625f5E9A3", | ||
"0x9623A7dfb605f693C9725278cF78bd2F53F0D407", | ||
"0xa4FBcd39Dc0E8c6B1c3d89751fF86855d8F5b98d", | ||
"0x9433601511580b7bd3F875C57E5a82Bf9A6a5997", | ||
"0x21631d18d9681D4fFDd460FC45fA52159fCd95c8", | ||
"0x1eE199C1832D4cFd075ad2708FEB75fC8c80b8C6", | ||
"0x52932f5B2767D917c3134140168f2176C94E8B2C", | ||
"0x1cC1983396E55e925b777A0D70dFe8b56EdEE942", | ||
"0xa8dd3c464c57881ee0411b7a5Ee9aC5430E83122", | ||
"0xdBdc061Ff54314f0A394f6F850fF2415c8D1DF1b", | ||
"0xE1D49F083207eEed71414c0AA28236e97b1793c0", | ||
"0xC823127743196981af46bC542028C3578e674C4e", | ||
"0x9E9EF0B615d4aF21C01121273498Ad5DEB5A3785", | ||
"0xC8B810Fe39952AA65CA5A9387a3546B9b6bF5780", | ||
"0xb61193014Fc983b3475d6bF365B7647c2E52b713", | ||
"0x34978fAf3A9f469da7248d1365Ddf69Ac099588C", | ||
"0x2C90f88BE812349fdD5655c9bAd8288c03E7fB23", | ||
"0x1dBA5711CC83D2F6502eFBfeBAc48B14714cCE2e", | ||
"0x18C2f8a7e2696d28661D59785B18C6794cd8D8e1", | ||
"0xdCf809BBa1d9ee75c6991f1E2974163cF2555418", | ||
"0x080d222fc30aC35f52d169faa9062Ec29D13d187", | ||
"0x138d65D1ca31A707E06ef148707b7Cee5f85E11E", | ||
"0xF654Cbd0d7B1765091b035BBB0205Dd4b6b49C7F", | ||
"0x03B79C0C1487a68AeabD9AA4ce779DaD77855F52", | ||
"0x0fb95b8C2d19F1Cbd2dfe9ECB3BdF992cB9E8b92", | ||
"0x091e2f9422A22a09E478455Fd59bE8CB6ee56463", | ||
"0xA5Cc7F3c81681429b8e4Fc074847083446CfDb99", | ||
"0xda6BB8C5507aff8C9eD9d787c1e8A82A0a79d629", | ||
"0xfB33ad9bBA1612Fd9deFb207cdA9a56263b55743", | ||
"0x596E7fe8a3FD3AB4dEdC227c848569a0265828Ff", | ||
"0x1015F376319B48C16078339534Fb9D83F75Bf15C", | ||
"0xAf751f153503D726FdAce94558FF4974CC688bDc", | ||
"0x8a32Af4AfFD816978C2Fdfa7C08c27681d05d4Fe", | ||
"0x40415c1c0E7a8ff3E184b51A94a2Fc5B92Df9434", | ||
"0xd30874ca82901D41FE66deD3012909D81924a0B8", | ||
"0x890F1815a0935B10126bcfe6Dd48CE37eD3064ed", | ||
"0xbbe3aba57ac2a5dc36eBb9769fCbD53FD5153F93" | ||
], | ||
"snapshot": 13315111 | ||
} | ||
] |
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,59 @@ | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'jordanmessina'; | ||
export const version = '0.1.0'; | ||
|
||
const lootAbi = [ | ||
'function balanceOf(address owner) external view returns (uint256 balance)', | ||
'function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId)' | ||
] | ||
|
||
const lootCharacterGuildsAbi = [ | ||
'function guildLoots(uint256 tokenId) external view returns (uint256 guild)' | ||
] | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const lootBalanceOfMulti = new Multicaller(network, provider, lootAbi, { blockTag }); | ||
addresses.forEach((address) => { | ||
lootBalanceOfMulti.call(address, options.lootAddress, 'balanceOf', [address]); | ||
}); | ||
const lootBalanceOfResult = await lootBalanceOfMulti.execute(); | ||
|
||
const lootTokenOwnerMulti = new Multicaller(network, provider, lootAbi, { blockTag }); | ||
for (const [address, balance] of Object.entries<number>(lootBalanceOfResult)) { | ||
for(let i=0; i < balance; i++) { | ||
lootTokenOwnerMulti.call(`${address}-${i}`, options.lootAddress, 'tokenOfOwnerByIndex', [address, String(i)]); | ||
} | ||
} | ||
const lootBagOwners = await lootTokenOwnerMulti.execute(); | ||
|
||
const guildLootsMulti = new Multicaller(network, provider, lootCharacterGuildsAbi, { blockTag }); | ||
for (const [addressAndBagIndex, bagId] of Object.entries(lootBagOwners)) { | ||
guildLootsMulti.call(addressAndBagIndex, options.lootCharacterGuildsAddress, 'guildLoots', [String(bagId)]); | ||
} | ||
const lootOwnerToGuild = await guildLootsMulti.execute(); | ||
|
||
const votes = {}; | ||
for (const [addressAndBagIndex, guild] of Object.entries(lootOwnerToGuild)) { | ||
if(String(guild) === String(options.guildId)) { | ||
let address = addressAndBagIndex.split('-')[0]; | ||
votes[address] = address in votes ? votes[address] + 1 : 1 | ||
} | ||
} | ||
|
||
return Object.fromEntries( | ||
addresses.map((address: any) => [ | ||
address, | ||
address in votes ? votes[address] : 0 | ||
]) | ||
); | ||
} |