Sub-Adapters 1
Preview and test each sub adapter.
RocketPool (rocketpool)
Metadata
- ID
- rocketpool
- name
"RocketPool"
- icon
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'RocketPool';
2export const version = '0.1.0';
3export const license = 'MIT';
4
5const RETH_ADDRESS = '0xae78736Cd615f374D3085123A210448E74Fc6393';
6
7const RETH_ABI = [
8 'function getExchangeRate() external view returns (uint256)',
9];
10
11export function setup(sdk: Context) {
12 const getTotalStaked = async () => {
13 const data = await sdk.graph.query('dmihal/rocketpool-mainnet', `{
14 rocketPoolProtocol(id: "ROCKETPOOL - DECENTRALIZED ETH2.0 STAKING PROTOCOL") {
15 lastNetworkStakerBalanceCheckPoint {
16 stakerETHActivelyStaking
17 }
18 }
19 }`);
20
21 return data.rocketPoolProtocol.lastNetworkStakerBalanceCheckPoint.stakerETHActivelyStaking / 1e18;
22 };
23
24 const getAPR = async () => {
25 const rethContract = sdk.ethers.getContract(RETH_ADDRESS, RETH_ABI);
26
27 const today = sdk.date.formatDate(new Date());
28 const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
29
30 const totalRewardsNow = await rethContract.getExchangeRate({ blockTag: today });
31 const totalRewardsWeekAgo = await rethContract.getExchangeRate({ blockTag: weekAgo });
32
33 const rewardDiff = totalRewardsNow.toString() - totalRewardsWeekAgo.toString()
34
35 return rewardDiff / 1e18 * 52;
36 };
37
38 sdk.register({
39 id: 'rocketpool',
40 queries: {
41 totalStakedETH: getTotalStaked,
42 apy: getAPR,
43 },
44 metadata: {
45 name: 'RocketPool',
46 icon: sdk.ipfs.getDataURILoader('Qmcv8uUczdZ3uHSKhHMoP9mCsPverUZDP8XjP9r3W1ohv8', 'image/png'),
47 },
48 })
49}
It's something off?
Report it to the discussion board on Discord, we will take care of it.