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.
added preliminary strategies for testing
- Loading branch information
1 parent
26c455b
commit 6abc8a4
Showing
7 changed files
with
189 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,13 @@ | ||
# rocketpool-delegation-v1 | ||
|
||
This is a strategy for Rocket Pool node operators to delegate their vote. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0xD33526068D116cE69F19A9ee46F0bd304F21A51f", | ||
"symbol": "RPL", | ||
"decimals": 18 | ||
} | ||
``` |
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,34 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "rocketpool-delegation-v1", | ||
"params": { | ||
"address": "0xD33526068D116cE69F19A9ee46F0bd304F21A51f", | ||
"symbol": "RPL", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x17Fa597cEc16Ab63A7ca00Fb351eb4B29Ffa6f46", | ||
"0xca317A4ecCbe0Dd5832dE2A7407e3c03F88b2CdD", | ||
"0x327260c50634136551bfE4e4eB082281555AAfAE", | ||
"0x5d8172792a9e649053c07366E3a7C24a37F0C534", | ||
"0x701F4dcEAD1049FA01F321d49F6dca525cF4A5A5", | ||
"0xb8ed9ea221bf33d37360A76DDD52bA7b1E66AA5C", | ||
"0xbfaf9BFa09F26EF8104A6d5FF09afdCC9300E5bc", | ||
"0x174E0b45C03318B0C9bc03573028605B26764931", | ||
"0x5f4cB66c9B1Ed8A4758A059FDB10E0F72C307D8A", | ||
"0x24609303B67051eF77735E34D671e2A13E3Da35d", | ||
"0xE35854CdE18A3cC4706134b4850Dd861a55B9A30", | ||
"0x53938f795AB6c57070AAd32905a70A2E5961A887", | ||
"0xD6527Bd3d62f1Da520E6f74B89EBD8F8cD04564f", | ||
"0xf8bFf17a1C9dfC632F6C905d12C404AfE451B16c", | ||
"0x689C6853f3deBac91b72f32BafA83200eeC9613C", | ||
"0xaEbb400542598E6ee58b2FDF2E7425c07E8Ba68D", | ||
"0xa016344b2D4dfBf370766F24d196171DeC86544A" | ||
], | ||
"snapshot": 17761214 | ||
} | ||
] |
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,56 @@ | ||
import { Multicaller } from '../../utils'; | ||
import { strategy as rocketpoolNodeOperatorv4 } from '../rocketpool-node-operator-v4'; | ||
|
||
export const author = 'rocket-pool'; | ||
export const version = '0.1.4'; | ||
|
||
// Holesky | ||
const rocketNetworkVotingAddress = '0x76caB8828324ba4ad32Eb1140057A485606aa791'; | ||
const rocketNetworkVotingAbi = ['function getCurrentDelegate(address) external view returns (address);']; | ||
Check failure on line 9 in src/strategies/rocketpool-delegation-v1/index.ts GitHub Actions / lint / Lint
|
||
|
||
// Mapping Contract | ||
const rocketDelegateMappingAddress = '0x76caB8828324ba4ad32Eb1140057A485606aa791'; | ||
const rocketDelegateMappingAbi = ['function getNodeAddress(address) external view returns (address);']; | ||
Check failure on line 13 in src/strategies/rocketpool-delegation-v1/index.ts GitHub Actions / lint / Lint
|
||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const signingDelegations = new Multicaller(network, provider, rocketDelegateMappingAbi, { blockTag }); | ||
addresses.forEach((address) => | ||
signingDelegations.call(address, rocketDelegateMappingAddress, 'getNodeAddress', [address]) | ||
Check failure on line 27 in src/strategies/rocketpool-delegation-v1/index.ts GitHub Actions / lint / Lint
|
||
); | ||
const nodeAddresses = await signingDelegations.execute(); | ||
if (Object.keys(nodeAddresses).length === 0) return {}; | ||
|
||
const delegations = new Multicaller(network, provider, rocketNetworkVotingAbi, { blockTag }); | ||
nodeAddresses.forEach((nodeAddress) => | ||
delegations.call(nodeAddress, rocketNetworkVotingAddress, 'getCurrentDelegate', [nodeAddress]) | ||
Check failure on line 34 in src/strategies/rocketpool-delegation-v1/index.ts GitHub Actions / lint / Lint
|
||
); | ||
const delegationsResponse = await delegations.execute(); | ||
if (Object.keys(delegationsResponse).length === 0) return {}; | ||
|
||
const score = await rocketpoolNodeOperatorv4( | ||
space, | ||
network, | ||
provider, | ||
delegationsResponse, | ||
options, | ||
snapshot | ||
); | ||
|
||
return Object.fromEntries( | ||
addresses.map((address) => { | ||
const addressScore = delegations[address] | ||
? delegations[address].reduce((a, b) => a + score[b], 0) | ||
: 0; | ||
return [address, addressScore]; | ||
}) | ||
); | ||
} |
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,13 @@ | ||
# rocketpool-node-operator-v3 | ||
|
||
This is a strategy for staking node operators, it returns the half square rooted node effective stake balance given a node address. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0xD33526068D116cE69F19A9ee46F0bd304F21A51f", | ||
"symbol": "RPL", | ||
"decimals": 18 | ||
} | ||
``` |
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,34 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "rocketpool-node-operator-v4", | ||
"params": { | ||
"address": "0xD33526068D116cE69F19A9ee46F0bd304F21A51f", | ||
"symbol": "RPL", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x17Fa597cEc16Ab63A7ca00Fb351eb4B29Ffa6f46", | ||
"0xca317A4ecCbe0Dd5832dE2A7407e3c03F88b2CdD", | ||
"0x327260c50634136551bfE4e4eB082281555AAfAE", | ||
"0x5d8172792a9e649053c07366E3a7C24a37F0C534", | ||
"0x701F4dcEAD1049FA01F321d49F6dca525cF4A5A5", | ||
"0xb8ed9ea221bf33d37360A76DDD52bA7b1E66AA5C", | ||
"0xbfaf9BFa09F26EF8104A6d5FF09afdCC9300E5bc", | ||
"0x174E0b45C03318B0C9bc03573028605B26764931", | ||
"0x5f4cB66c9B1Ed8A4758A059FDB10E0F72C307D8A", | ||
"0x24609303B67051eF77735E34D671e2A13E3Da35d", | ||
"0xE35854CdE18A3cC4706134b4850Dd861a55B9A30", | ||
"0x53938f795AB6c57070AAd32905a70A2E5961A887", | ||
"0xD6527Bd3d62f1Da520E6f74B89EBD8F8cD04564f", | ||
"0xf8bFf17a1C9dfC632F6C905d12C404AfE451B16c", | ||
"0x689C6853f3deBac91b72f32BafA83200eeC9613C", | ||
"0xaEbb400542598E6ee58b2FDF2E7425c07E8Ba68D", | ||
"0xa016344b2D4dfBf370766F24d196171DeC86544A" | ||
], | ||
"snapshot": 17761214 | ||
} | ||
] |
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,35 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'rocket-pool'; | ||
export const version = '0.1.3'; | ||
|
||
// Holesky | ||
const rocketNetworkVotingAddress = '0x76caB8828324ba4ad32Eb1140057A485606aa791'; | ||
const rocketNetworkVotingAbi = ['function getVotingPower(address, uint32) external view returns (uint256)']; | ||
Check failure on line 10 in src/strategies/rocketpool-node-operator-v4/index.ts GitHub Actions / lint / Lint
|
||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const votingPower = new Multicaller(network, provider, rocketNetworkVotingAbi, { blockTag }); | ||
addresses.forEach((address) => | ||
votingPower.call(address, rocketNetworkVotingAddress, 'getVotingPower', [address, blockTag]) | ||
); | ||
|
||
const result: Record<string, BigNumberish> = await votingPower.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address, balance]) => [ | ||
address, | ||
parseFloat(formatUnits(balance, options.decimals)) | ||
]) | ||
); | ||
} |