Skip to content

Commit

Permalink
added preliminary strategies for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdoherty committed May 13, 2024
1 parent 26c455b commit 6abc8a4
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ import * as positionGovernancePower from './position-governance-power';
import * as creditLp from './credit-lp';
import * as helix from './helix';
import * as auraBalanceOfSingleAsset from './aura-vault-balance-of-single-asset';
import * as rocketpoolDelegationv1 from './rocketpool-delegation-v1';
import * as rocketpoolNodeOperator from './rocketpool-node-operator';
import * as rocketpoolNodeOperatorv2 from './rocketpool-node-operator-v2';
import * as rocketpoolNodeOperatorv3 from './rocketpool-node-operator-v3';
import * as rocketpoolNodeOperatorv4 from './rocketpool-node-operator-v4';
import * as earthfundChildDaoStakingBalance from './earthfund-child-dao-staking-balance';
import * as unipilotVaultPilotBalance from './unipilot-vault-pilot-balance';
import * as sdBoostTWAVP from './sd-boost-twavp';
Expand Down Expand Up @@ -727,9 +729,11 @@ const strategies = {
'credit-lp': creditLp,
helix,
'aura-vault-balance-of-single-asset': auraBalanceOfSingleAsset,
'rocketpool-delegation-v2': rocketpoolDelegationv1,
'rocketpool-node-operator': rocketpoolNodeOperator,
'rocketpool-node-operator-v2': rocketpoolNodeOperatorv2,
'rocketpool-node-operator-v3': rocketpoolNodeOperatorv3,
'rocketpool-node-operator-v4': rocketpoolNodeOperatorv4,
'earthfund-child-dao-staking-balance': earthfundChildDaoStakingBalance,
'sd-boost-twavp': sdBoostTWAVP,
'unipilot-vault-pilot-balance': unipilotVaultPilotBalance,
Expand Down
13 changes: 13 additions & 0 deletions src/strategies/rocketpool-delegation-v1/README.md
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
}
```
34 changes: 34 additions & 0 deletions src/strategies/rocketpool-delegation-v1/examples.json
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
}
]
56 changes: 56 additions & 0 deletions src/strategies/rocketpool-delegation-v1/index.ts
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

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `'function·getCurrentDelegate(address)·external·view·returns·(address);'` with `⏎··'function·getCurrentDelegate(address)·external·view·returns·(address);'⏎`

// Mapping Contract
const rocketDelegateMappingAddress = '0x76caB8828324ba4ad32Eb1140057A485606aa791';

Check failure on line 12 in src/strategies/rocketpool-delegation-v1/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `⏎·`
const rocketDelegateMappingAbi = ['function getNodeAddress(address) external view returns (address);'];

Check failure on line 13 in src/strategies/rocketpool-delegation-v1/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `'function·getNodeAddress(address)·external·view·returns·(address);'` with `⏎··'function·getNodeAddress(address)·external·view·returns·(address);'⏎`

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 });

Check failure on line 25 in src/strategies/rocketpool-delegation-v1/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `network,·provider,·rocketDelegateMappingAbi,·{·blockTag·}` with `⏎····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

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `address,·rocketDelegateMappingAddress,·'getNodeAddress',·[address]` with `⏎······address,⏎······rocketDelegateMappingAddress,⏎······'getNodeAddress',⏎······[address]⏎····`
);
const nodeAddresses = await signingDelegations.execute();
if (Object.keys(nodeAddresses).length === 0) return {};

const delegations = new Multicaller(network, provider, rocketNetworkVotingAbi, { blockTag });

Check failure on line 32 in src/strategies/rocketpool-delegation-v1/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `network,·provider,·rocketNetworkVotingAbi,·{·blockTag·}` with `⏎····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

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `nodeAddress,·rocketNetworkVotingAddress,·'getCurrentDelegate',·[nodeAddress]` with `⏎······nodeAddress,⏎······rocketNetworkVotingAddress,⏎······'getCurrentDelegate',⏎······[nodeAddress]⏎····`
);
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];
})
);
}
13 changes: 13 additions & 0 deletions src/strategies/rocketpool-node-operator-v4/README.md
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
}
```
34 changes: 34 additions & 0 deletions src/strategies/rocketpool-node-operator-v4/examples.json
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
}
]
35 changes: 35 additions & 0 deletions src/strategies/rocketpool-node-operator-v4/index.ts
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

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `'function·getVotingPower(address,·uint32)·external·view·returns·(uint256)'` with `⏎··'function·getVotingPower(address,·uint32)·external·view·returns·(uint256)'⏎`

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 });

Check failure on line 22 in src/strategies/rocketpool-node-operator-v4/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `network,·provider,·rocketNetworkVotingAbi,·{·blockTag·}` with `⏎····network,⏎····provider,⏎····rocketNetworkVotingAbi,⏎····{·blockTag·}⏎··`
addresses.forEach((address) =>
votingPower.call(address, rocketNetworkVotingAddress, 'getVotingPower', [address, blockTag])

Check failure on line 24 in src/strategies/rocketpool-node-operator-v4/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Replace `address,·blockTag` with `⏎······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))
])
);
}

0 comments on commit 6abc8a4

Please sign in to comment.