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.6';
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    // APY based on the formula: apy = (end − beginning) ÷ beginning × 365/7.
51    const apy = ((totalRewardsNow - totalRewardsWeekAgo) / totalRewardsWeekAgo) * (365/7);
52
53    return apy;
54  };
55
56  const getDiscount = async () => {
57    const rethContract = sdk.ethers.getContract(RETH_ADDRESS, RETH_ABI);
58    const pool = sdk.ethers.getContract(UNI_POOL, UNIV3_POOL_ABI);
59
60    const output = await pool.slot0();
61    const outputRETH =  (output.sqrtPriceX96 / (2 ** 96)) ** 2;
62    // // output RETH is market price
63    const exchangeRate = await rethContract.getExchangeRate();
64    const exchangeRateDecimal = exchangeRate / 1e18;
65    // exchangeRateDecimal is ETH per RETH in RETH smart contract
66    const nominalDiscount =  (outputRETH - exchangeRateDecimal);
67    const percentChange = (nominalDiscount / exchangeRateDecimal) ;
68
69    return 1 + percentChange;
70  };
71
72
73  sdk.register({
74    id: 'rocketpool',
75    queries: {
76      totalStakedETH: getTotalStaked,
77      apy: getAPR,
78      underlyingAssetMarketRate: getDiscount,
79    },
80    metadata: {
81      name: 'RocketPool',
82      icon: sdk.ipfs.getDataURILoader('Qmcv8uUczdZ3uHSKhHMoP9mCsPverUZDP8XjP9r3W1ohv8', 'image/png'),
83      tokenAddress: '0xae78736cd615f374d3085123a210448e74fc6393',
84      tokenSymbol: 'RETH',
85      website: 'https://rocketpool.net',
86      governanceTokenSymbol: 'RPL',
87      governanceTokenCoingecko: 'rocket-pool',
88    },
89  })
90}

It's something off?

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

Adapter Info

Version

0.2.6

License

MIT

IPFS CID

QmTWtPv9LpxkL5FeQae7Zp8hFK3f5XJ6jQ5VpDV97eqvaU

CID (source)

QmX9EDh9jMPmXtvbJ1WDu7dwzgQEw7Jho9Kq517gUwvuXR

Author

0x3eb44F405DEEa44CCffD817f0f46F1FFB1e5BcE9