Sub-Adapters 1

Preview and test each sub adapter.

Stakewise (stakewise)

Metadata

ID
stakewise
name

"Stakewise"

icon
tokenAddress

"0xFe2e637202056d30016725477c5da089Ab0A043A"

tokenSymbol

"SETH2"

website

"https://stakewise.io"

governanceTokenSymbol

"WISE"

governanceTokenCoingecko

"stakewise"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Stakewise';
2export const version = '0.2.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
12const UNI_POOL = '0x7379e81228514a1d2a6cf7559203998e20598346';
13
14const UNIV3_POOL_ABI = [
15  `function slot0()
16    external
17    view
18    returns (
19        uint160 sqrtPriceX96,
20        int24 tick,
21        uint16 observationIndex,
22        uint16 observationCardinality,
23        uint16 observationCardinalityNext,
24        uint8 feeProtocol,
25        bool unlocked
26    )`
27];
28
29export function setup(sdk: Context) {
30  const getTotalStaked = async () => {
31    const stETHToken = sdk.ethers.getERC20Contract(STETH_ADDRESS);
32    const supply = await stETHToken.totalSupply();
33    return supply.toString() / 1e18;
34  };
35
36  const getAPR = async () => {
37    const rETHContract = sdk.ethers.getContract(rETH_ADDRESS, rETH2_ABI);
38
39    const today = sdk.date.formatDate(new Date());
40    const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
41
42    const totalRewardsNow = await rETHContract.rewardPerToken({ blockTag: today });
43    const totalRewardsWeekAgo = await rETHContract.rewardPerToken({ blockTag: weekAgo });
44
45    const rewardDiff = totalRewardsNow.toString() - totalRewardsWeekAgo.toString()
46
47    return rewardDiff / 1e18 * 52;
48  };
49
50  const getDiscount = async () => {
51    const pool = sdk.ethers.getContract(UNI_POOL, UNIV3_POOL_ABI);
52
53    const output = await pool.slot0();
54
55    return 1 / (output.sqrtPriceX96 / (2 ** 96)) ** 2;
56  };
57
58  sdk.register({
59    id: 'stakewise',
60    queries: {
61      totalStakedETH: getTotalStaked,
62      apy: getAPR,
63      underlyingAssetMarketRate: getDiscount,
64    },
65    metadata: {
66      name: 'Stakewise',
67      icon: sdk.ipfs.getDataURILoader('QmNY4zeXxbQ2wn1vBfQGDeq43DxEhDQhnukEqSfriQDAFb', 'image/svg+xml'),
68      tokenAddress: '0xFe2e637202056d30016725477c5da089Ab0A043A',
69      tokenSymbol: 'SETH2',
70      website: 'https://stakewise.io',
71      governanceTokenSymbol: 'WISE',
72      governanceTokenCoingecko: 'stakewise',
73    },
74  })
75}
76

It's something off?

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

Adapter Info

Version

0.2.1

License

MIT

IPFS CID

QmV9nGfKat64dJ4M7DrAE9W9beXehRWCiwRVijcJBykHU5

CID (source)

QmTx6KTJXr6ou4Te7gAYvPaMc1NJENntjWUgGM2W2G7E1A

Author

mihal.eth