Adapter

Stakewise

Sub-Adapters 1

Preview and test each sub adapter.

Stakewise (stakewise)

Metadata

ID
stakewise
name

"Stakewise"

icon

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Stakewise';
2export const version = '0.1.1';
3export const license = 'MIT';
4
5const STETH_ADDRESS = '0xFe2e637202056d30016725477c5da089Ab0A043A';
6const rETH_ADDRESS = '0x20bc832ca081b91433ff6c17f85701b6e92486c5';
7
8const rETH2_ABI = [
9  'function rewardPerToken() external view returns (uint128)',
10];
11
12export function setup(sdk: Context) {
13  const getTotalStaked = async () => {
14    const stETHToken = sdk.ethers.getERC20Contract(STETH_ADDRESS);
15    const supply = await stETHToken.totalSupply();
16    return supply.toString() / 1e18;
17  };
18
19  const getAPR = async () => {
20    const rETHContract = sdk.ethers.getContract(rETH_ADDRESS, rETH2_ABI);
21
22    const today = sdk.date.formatDate(new Date());
23    const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
24
25    const totalRewardsNow = await rETHContract.rewardPerToken({ blockTag: today });
26    const totalRewardsWeekAgo = await rETHContract.rewardPerToken({ blockTag: weekAgo });
27
28    const rewardDiff = totalRewardsNow.toString() - totalRewardsWeekAgo.toString()
29
30    return rewardDiff / 1e18 * 52;
31  };
32
33  sdk.register({
34    id: 'stakewise',
35    queries: {
36      totalStakedETH: getTotalStaked,
37      apy: getAPR,
38    },
39    metadata: {
40      name: 'Stakewise',
41      icon: sdk.ipfs.getDataURILoader('QmNY4zeXxbQ2wn1vBfQGDeq43DxEhDQhnukEqSfriQDAFb', 'image/svg+xml'),
42    },
43  })
44}
45

It's something off?

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

Adapter Info

Version

0.1.1

License

MIT

IPFS CID

QmPv736F41wH9mciEQB2QEFnPWuVBebzuXUhdsMwAHyUMS

CID (source)

QmQZ7Fhe5YgpcMampdENj8bwsrZ4RRRrks1CfxvrReoe7y

Author

mihal.eth