Skip to content

Commit

Permalink
add restaking rewards apy (#1613)
Browse files Browse the repository at this point in the history
* add restaking rewards apy

* fix apr and not in wei

* provide rewards token which wraps eigens
  • Loading branch information
vvalecha519 authored Nov 22, 2024
1 parent bee0f64 commit c124484
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/adaptors/ether.fi-stake/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const sdk = require('@defillama/sdk');
const axios = require('axios');

const weETH = '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee';
const eETH = '0x35fA164735182de50811E8e2E824cFb9B6118ac2'
const weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
const eigen = '0xec53bf9167f50cdeb3ae105f56099aaab9061f83';
const lrt2 = '0x8F08B70456eb22f6109F57b8fafE862ED28E6040';

const apy = async () => {
const totalSupply =
Expand All @@ -13,6 +16,14 @@ const apy = async () => {
})
).output / 1e18;

const totalSupplyEETH =
(
await sdk.api.abi.call({
target: eETH,
abi: 'erc20:totalSupply',
})
).output / 1e18;

const now = Math.floor(Date.now() / 1000);
const timestamp1dayAgo = now - 86400;
const timestamp7dayAgo = now - 86400 * 7;
Expand Down Expand Up @@ -51,10 +62,27 @@ const apy = async () => {
365 *
100;


const optimismApi = new sdk.ChainApi({ chain: 'optimism' });
const restakingWeeklyEigen = Number(await optimismApi.call({
target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da',
abi: 'function categoryTVL(string _category) view returns (uint256)',
params: [eigen]
})) / 1e18;

const priceKey = `ethereum:${weETH}`;
const priceKeyEigen = `ethereum:${eigen}`;
const priceKeyEETH = `ethereum:${eETH}`;
const eigenPrice = (
await axios.get(`https://coins.llama.fi/prices/current/ethereum:${eigen}`)
).data.coins[`ethereum:${eigen}`]?.price;
const eethPrice = (
await axios.get(`https://coins.llama.fi/prices/current/ethereum:${eETH}`)
).data.coins[`ethereum:${eETH}`]?.price;
const price = (
await axios.get(`https://coins.llama.fi/prices/current/${priceKey}`)
).data.coins[priceKey]?.price;
const restakingApy = (restakingWeeklyEigen * eigenPrice) / 7 / (totalSupplyEETH * eethPrice) * 365 * 100;

return [
{
Expand All @@ -65,7 +93,9 @@ const apy = async () => {
tvlUsd: totalSupply * price,
apyBase: apr1d,
apyBase7d: apr7d,
apyReward: restakingApy,
underlyingTokens: [weth],
rewardTokens: [lrt2],
},
];
};
Expand Down

0 comments on commit c124484

Please sign in to comment.