Sub-Adapters 1

Preview and test each sub adapter.

Lido (lido)

Metadata

ID
lido
name

"Lido"

icon
tokenAddress

"0xae7ab96520de3a18e5e111b5eaab095312d7fe84"

tokenSymbol

"stETH"

website

"https://lido.fi"

governanceTokenSymbol

"LDO"

governanceTokenCoingecko

"lido-dao"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Lido';
2export const version = '0.2.1';
3export const license = 'MIT';
4
5const STETH_ADDRESS = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84';
6
7const STETH_ABI = [
8  'function getPooledEthByShares(uint256 shares) external view returns (uint256 pooledEth)',
9  'function getBeaconStat() external view returns (uint256, uint256, uint256)',
10];
11
12const CURVE_POOL = '0xDC24316b9AE028F1497c275EB9192a3Ea0f67022';
13
14const CURVE_ABI = [
15  'function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256)',
16];
17
18
19const ONE_SHARE = '1000000000000000000';
20
21export function setup(sdk: Context) {
22  const getTotalStaked = async () => {
23    const stethContract = sdk.ethers.getContract(STETH_ADDRESS, STETH_ABI);
24
25    const beaconStats = await stethContract.getBeaconStat();
26    const numValidators = beaconStats[0].toString();
27
28    return numValidators * 32;
29  };
30
31  const getAPR = async () => {
32    const stethContract = sdk.ethers.getContract(STETH_ADDRESS, STETH_ABI);
33
34    const today = sdk.date.formatDate(new Date());
35    const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
36
37    const totalRewardsNow = await stethContract.getPooledEthByShares(ONE_SHARE, { blockTag: today });
38    const totalRewardsWeekAgo = await stethContract.getPooledEthByShares(ONE_SHARE, { blockTag: weekAgo });
39
40    const rewardDiff = totalRewardsNow.toString() - totalRewardsWeekAgo.toString()
41
42    return rewardDiff / 1e18 * 52;
43  };
44
45  const getDiscount = async () => {
46    const curve = sdk.ethers.getContract(CURVE_POOL, CURVE_ABI);
47
48    const output = await curve.get_dy(1, 0, '1000000000000000000');
49
50    return output / 1e18;
51  };
52
53  sdk.register({
54    id: 'lido',
55    queries: {
56      totalStakedETH: getTotalStaked,
57      apy: getAPR,
58      underlyingAssetMarketRate: getDiscount,
59    },
60    metadata: {
61      name: 'Lido',
62      icon: sdk.ipfs.getDataURILoader('QmcsGcopqrVyzTLXETtecJuhqxqxbzUvuFMqBd27yFKCMt', 'image/svg+xml'),
63      tokenAddress: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
64      tokenSymbol: 'stETH',
65      website: 'https://lido.fi',
66      governanceTokenSymbol: 'LDO',
67      governanceTokenCoingecko: 'lido-dao',
68    },
69  })
70}
71

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

QmRf4VJXsdivXRz1hzPYg1yQh5u359wzVrLVy2CwXUo7j3

CID (source)

Qme86aXjZqCAPDuNr6kMwarkkCqToZTFrM3tCitA297Hey

Author

mihal.eth