Sub-Adapters 1

Preview and test each sub adapter.

RocketPool (rocketpool)

Metadata

ID
rocketpool
name

"RocketPool"

icon
tokenAddress

"0xae78736cd615f374d3085123a210448e74fc6393"

tokenSymbol

"RETH"

website

"https://rocketpool.net"

governanceTokenSymbol

"RPL"

governanceTokenCoingecko

"rocket-pool"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'RocketPool';
2export const version = '0.2.5';
3export const license = 'MIT';
4
5const RETH_ADDRESS = '0xae78736Cd615f374D3085123A210448E74Fc6393';
6
7const RETH_ABI = [
8  'function getExchangeRate() external view returns (uint256)',
9];
10
11const UNI_POOL = '0xa4e0faA58465A2D369aa21B3e42d43374c6F9613';
12
13const UNIV3_POOL_ABI = [
14  `function slot0()
15    external
16    view
17    returns (
18        uint160 sqrtPriceX96,
19        int24 tick,
20        uint16 observationIndex,
21        uint16 observationCardinality,
22        uint16 observationCardinalityNext,
23        uint8 feeProtocol,
24        bool unlocked
25    )`
26];
27
28export function setup(sdk: Context) {
29  const getTotalStaked = async () => {
30    const data = await sdk.graph.query('dmihal/rocketpool-mainnet', `{
31      rocketPoolProtocol(id: "ROCKETPOOL - DECENTRALIZED ETH2.0 STAKING PROTOCOL") {
32        lastNetworkStakerBalanceCheckPoint {
33          stakerETHActivelyStaking
34        }
35      }
36    }`);
37
38    return data.rocketPoolProtocol.lastNetworkStakerBalanceCheckPoint.stakerETHActivelyStaking / 1e18;
39  };
40
41  const getAPR = async () => {
42    const rethContract = sdk.ethers.getContract(RETH_ADDRESS, RETH_ABI);
43
44    const today = sdk.date.formatDate(new Date());
45    const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
46
47    const totalRewardsNow = await rethContract.getExchangeRate({ blockTag: today });
48    const totalRewardsWeekAgo = await rethContract.getExchangeRate({ blockTag: weekAgo });
49
50    const rewardDiff = totalRewardsNow.toString() - totalRewardsWeekAgo.toString()
51
52    return rewardDiff / 1e18 * 52;
53  };
54
55  const getDiscount = async () => {
56    const rethContract = sdk.ethers.getContract(RETH_ADDRESS, RETH_ABI);
57    const pool = sdk.ethers.getContract(UNI_POOL, UNIV3_POOL_ABI);
58
59    const output = await pool.slot0();
60    const outputRETH =  (output.sqrtPriceX96 / (2 ** 96)) ** 2;
61    // // output RETH is market price
62    const exchangeRate = await rethContract.getExchangeRate();
63    const exchangeRateDecimal = exchangeRate / 1e18;
64    // exchangeRateDecimal is ETH per RETH in RETH smart contract
65    const nominalDiscount =  (outputRETH - exchangeRateDecimal);
66    const percentChange = (nominalDiscount / exchangeRateDecimal) ;
67
68    return 1 + percentChange;
69  };
70
71
72  sdk.register({
73    id: 'rocketpool',
74    queries: {
75      totalStakedETH: getTotalStaked,
76      apy: getAPR,
77      underlyingAssetMarketRate: getDiscount,
78    },
79    metadata: {
80      name: 'RocketPool',
81      icon: sdk.ipfs.getDataURILoader('Qmcv8uUczdZ3uHSKhHMoP9mCsPverUZDP8XjP9r3W1ohv8', 'image/png'),
82      tokenAddress: '0xae78736cd615f374d3085123a210448e74fc6393',
83      tokenSymbol: 'RETH',
84      website: 'https://rocketpool.net',
85      governanceTokenSymbol: 'RPL',
86      governanceTokenCoingecko: 'rocket-pool',
87    },
88  })
89}

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.2.5

License

MIT

IPFS CID

QmQGa1JYx3gpnCgCCCfXPWyddNZqe7FJL8jCATv25Xu6wd

CID (source)

QmScU98kwWtAPdcBaiLPmTcUDji4szHrx1CH5rPGgTfe5F

Author

0x3eb44F405DEEa44CCffD817f0f46F1FFB1e5BcE9