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.
[cyberkongz] Add cyberkongz strategy (snapshot-labs#90)
* Add cyberkongz strategy * Update src/strategies/cyberkongz/index.ts Co-authored-by: Chaitanya <[email protected]>
- Loading branch information
Showing
3 changed files
with
77 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
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 | ||
}] | ||
|
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,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; | ||
} |
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