Sub-Adapters 1

Preview and test each sub adapter.

Ankr (ankr)

Metadata

ID
ankr
name

"Ankr"

icon
tokenSymbol

"aETHc"

tokenAddress

"0xE95A203B1a91a908F9B9CE46459d101078c2c3cb"

website

"https://ankr.com"

governanceTokenSymbol

"ANKR"

governanceTokenCoingecko

"ankr-network"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Ankr';
2export const version = '0.1.6';
3export const license = 'MIT';
4
5const aETHc_ADDRESS = '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb';
6const aETHb_ADDRESS = '0xD01ef7C0A5d8c432fc2d1a85c66cF2327362E5C6';
7
8const aETHc_ABI = [
9  'function ratio() public view returns (uint256)',
10];
11
12const CURVE_POOL = '0xa96a65c051bf88b4095ee1f2451c2a9d43f53ae2';
13
14const CURVE_ABI = [
15  'function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256)',
16];
17
18export function setup(sdk: Context) {
19  const getTotalStakedForToken = async (tokenAddress: string) => {
20    const token = sdk.ethers.getERC20Contract(tokenAddress);
21    const supply = await token.totalSupply();
22    return supply.toString() / 1e18;
23  }
24
25  const getTotalStaked = async () => {
26 
27    let totalStaked = await getTotalStakedForToken(aETHb_ADDRESS) + await getTotalStakedForToken(aETHc_ADDRESS); 
28    return totalStaked ;
29  }
30
31  const getAPR = async () => {
32    const aETHcContract = sdk.ethers.getContract(aETHc_ADDRESS, aETHc_ABI);
33
34    const today = sdk.date.formatDate(new Date());
35    const weekAgo = sdk.date.offsetDaysFormatted(today, -7);
36
37    const ratioNow = await aETHcContract.ratio({blockTag: today});
38    const ratioWeekAgo = await aETHcContract.ratio({blockTag: weekAgo});
39
40    // get accumulated rewards per eth staked using '1e18 / ratio' 
41    // comparing inverse rewards now to aETHc rate shown on:
42    //  https://www.ankr.com/staking/stake/ethereum/?token=aETHc
43    sdk.log({inverseRewardsNow: 1e18 / ratioNow, inverseRewardsLastWeek: 1e18 / ratioWeekAgo});
44
45    const  rewardsDiff = (1e18 / ratioNow) - (1e18 / ratioWeekAgo);
46    return rewardsDiff * 52;
47  }
48
49  const getDiscount = async () => {
50    const aETHcContract = sdk.ethers.getContract(aETHc_ADDRESS, aETHc_ABI);
51    const curve = sdk.ethers.getContract(CURVE_POOL, CURVE_ABI);
52
53    const output = await curve.get_dy(1, 0, '1000000000000000000');
54    const outputAETHCperETH = output / 1e18;
55    const ratioNow = await aETHcContract.ratio();
56
57    return outputAETHCperETH / (1e18 / ratioNow);
58  };
59
60
61  sdk.register({
62    id: 'ankr',
63    queries: {
64      totalStakedETH: getTotalStaked,
65      apy: getAPR,
66      underlyingAssetMarketRate: getDiscount,
67    },
68    metadata: {
69      name: 'Ankr',
70      icon: sdk.ipfs.getDataURILoader('QmedFW6x588qnxWgQP9RZiNs27AXF3kREptY1cuaXXPRVS', 'image/svg+xml'),
71      tokenSymbol: 'aETHc',
72      tokenAddress: '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb',
73      website: 'https://ankr.com',
74      governanceTokenSymbol: 'ANKR',
75      governanceTokenCoingecko: 'ankr-network',
76    },
77  });
78}
79
80
81

It's something off?

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

Adapter Info

Version

0.1.6

License

MIT

IPFS CID

QmeQbVtGqe4874McDHZrdy974yAFz9EfYhvhAcg2PDZo8a

CID (source)

QmchuoLULVfKLkpQ5NKB2cea15C6H14eZPqSAaCeSNybhR

Author

ap0calyp.eth