Skip to content

Commit

Permalink
fix for defillama (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
brightiron committed Jul 11, 2023
1 parent 00332f4 commit 5578c18
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/views/Liquidity/hooks/useGetSingleSidedLiquidityVaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ export const getVaultInfo = async (address: string, network: number, walletAddre
let apySum = 0;
let rewards: { tokenName: string; apy: string; userRewards: string }[];
let apyBreakdown = { baseApy: 0, rewardApy: 0 };
console.log("address", address);
const apyData = await axios.get<defillamaAPI>("https://yields.llama.fi/pools").then(res => {
return res.data;
});

//Need to do this because contract method does not account for stETH rewards.
if (address.toLowerCase() === "0xafe729d57d2CC58978C2e01b4EC39C47FB7C4b23".toLowerCase()) {
//OHM-WSTETH Defillama
const apyData = await axios
.get<defillamaAPI>("https://yields.llama.fi/poolsEnriched?pool=10c1698f-bc44-4fbf-8287-2540acf45eff")
.then(res => {
return res.data.data[0];
});
const { apyReward = 0, apyBase = 0 } = apyData;
const pool = apyData.data.find(pool => pool.pool === "10c1698f-bc44-4fbf-8287-2540acf45eff") || {
apyReward: 0,
apyBase: 0,
};
const { apyReward = 0, apyBase = 0 } = pool;
apySum = apyReward + apyBase;

rewards = await Promise.all(
Expand All @@ -135,13 +135,12 @@ export const getVaultInfo = async (address: string, network: number, walletAddre
);
apyBreakdown = { baseApy: apyBase, rewardApy: apyReward };
} else if (address.toLowerCase() === "0xF451c45C7a26e2248a0EA02382579Eb4858cAdA1".toLowerCase()) {
//LUSD-OHM
const apyData = await axios
.get<defillamaAPI>("https://yields.llama.fi/poolsEnriched?pool=b2ef1e2c-722c-4804-978d-4ce0b7316e8e")
.then(res => {
return res.data.data[0];
});
const { apyReward = 0, apyBase = 0 } = apyData;
const pool = apyData.data.find(pool => pool.pool === "b2ef1e2c-722c-4804-978d-4ce0b7316e8e") || {
apyReward: 0,
apyBase: 0,
};

const { apyReward = 0, apyBase = 0 } = pool;
apySum = apyReward + apyBase;

rewards = await Promise.all(
Expand Down

0 comments on commit 5578c18

Please sign in to comment.