Skip to content

Commit

Permalink
[cyberkongz] Add cyberkongz strategy (snapshot-labs#90)
Browse files Browse the repository at this point in the history
* Add cyberkongz strategy

* Update src/strategies/cyberkongz/index.ts

Co-authored-by: Chaitanya <[email protected]>
  • Loading branch information
cesarsld and ChaituVR authored Oct 1, 2021
1 parent a8bba53 commit e043857
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/strategies/cyberkongz/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[{
"name": "CyberKongz, CyberKongz VX and Banana holdings",
"strategy": {
"name": "cyberkongz",
"params": {
"symbol": "KONGZ",
"registries": [
"0x57a204aa1042f6e66dd7730813f4024114d74f37",
"0x7ea3cca10668b8346aec0bf1844a49e995527c8b",
"0xe2311ae37502105b442bbef831e9b53c5d2e9b3b"
]
}
},
"network": "1",
"addresses": [
"0xf521Bb7437bEc77b0B15286dC3f49A87b9946773",
"0x721931508df2764fd4f70c53da646cb8aed16ace",
"0xa63571f2ce7cf4e9a566a1f248f5d0ad3ba78726",
"0x9279c4cfb0e85e2dff8825ce141f9794c7c7170a",
"0x6f35b0cfc58eb1e21eef8a439bbb0ce4c929d32a",
"0xe34bded2b256430a9be53cbf5cba3b6d866d55f3",
"0x031c690be2932403cbdd85f8853f596794cff6c3"
],
"snapshot": 13322697
}]

48 changes: 48 additions & 0 deletions src/strategies/cyberkongz/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { formatUnits } from '@ethersproject/units';
import { multicall } from '../../utils';

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

const abi = [
'function balanceOf(address account) external view returns (uint256)',
'function totalSupply() external view returns (uint256)'
];

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

const calls: any[] = [];
options.registries.forEach((registry) => {
addresses.forEach((address: any) => {
calls.push([registry, 'balanceOf', [address]]);
});
});

const response = await multicall(network, provider, abi, calls, { blockTag });
const nanaCall = [['0xe2311ae37502105b442bbef831e9b53c5d2e9b3b', 'totalSupply', []]]
const nanaSupply = await multicall(network, provider, abi, nanaCall, { blockTag });


const merged = {};
response.map((value: any, i: number) => {

const address = calls[i][2][0];
merged[address] = (merged[address] || 0) as number;
if(Math.floor(i / addresses.length) == 0)
merged[address] += parseFloat(formatUnits((3 * value).toString(), 0));
else if(Math.floor(i / addresses.length) == 1)
merged[address] += parseFloat(formatUnits(value.toString(), 0));
else if(Math.floor(i / addresses.length) == 2)
merged[address] += parseFloat(formatUnits((Math.floor(15000 * value / nanaSupply)).toString(), 0));
});

return merged;
}
4 changes: 3 additions & 1 deletion src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ import * as occStakeOf from './occ-stake-of';
import * as hoprStaking from './hopr-staking';
import * as hoprBridgedBalance from './hopr-bridged-balance';
import * as lootCharacterGuilds from './loot-character-guilds';
import * as cyberkongz from './cyberkongz';

const strategies = {
coordinape,
Expand Down Expand Up @@ -311,7 +312,8 @@ const strategies = {
'hopr-bridged-balance': hoprBridgedBalance,
'occ-stake-of': occStakeOf,
'holds-tokens': holdsTokens,
'loot-character-guilds': lootCharacterGuilds
'loot-character-guilds': lootCharacterGuilds,
'cyberkongz': cyberkongz
};

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

0 comments on commit e043857

Please sign in to comment.