Skip to content

Commit

Permalink
Add more blend pool yields (#1662)
Browse files Browse the repository at this point in the history
* use unique pool ids for each blend pool and asset

* simplify logic for adding pools to the return array

* remove url change

* fix a typo
  • Loading branch information
ElliotFriend authored Dec 19, 2024
1 parent 6c0f1a4 commit 01ac823
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/adaptors/blend-pools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const getApy = async (poolId, backstop) => {
if (borrowEmissionsPerAsset > 0) {
borrowEmissionsAPR = (borrowEmissionsPerAsset * usdcPerBlnd) / price;
}
// Estimate borrow APY compoumded daily
// Estimate borrow APY compounded daily
const borrowApy = (1 + reserve.borrowApr / 365) ** 365 - 1;
let totalSupply = reserve.totalSupplyFloat() * price;
let totalBorrow = reserve.totalLiabilitiesFloat() * price;

const url = `https://mainnet.blend.capital/dashboard/?poolId=${poolId}`;

pools.push({
pool: `${reserve.assetId}-stellar`.toLowerCase(),
pool: `${pool.id}-${reserve.assetId}-stellar`.toLowerCase(),
chain: formatChain('stellar'),
project: 'blend-pools',
symbol: reserve.tokenMetadata.symbol,
Expand All @@ -66,7 +66,7 @@ const getApy = async (poolId, backstop) => {
apyBaseBorrow: borrowApy * 100,
apyRewardBorrow: borrowEmissionsAPR * 100,
ltv: totalBorrow / totalSupply,
poolMeta: `Pool ID: ${pool.id}`,
poolMeta: `${pool.config.name} Pool`,
url,
});
}
Expand All @@ -80,18 +80,7 @@ const apy = async () => {

for (const poolId of BLEND_POOLS) {
let poolApys = await getApy(poolId, backstop);
for (const poolApy of poolApys) {
if (poolApy) {
let index = pools.findIndex((pool) => pool.pool == poolApy.pool);
if (index !== -1) {
if (poolApy.apyReward > pools[index].apyReward) {
pools[index] = poolApy;
}
} else {
pools.push(poolApy);
}
}
}
pools.push(...poolApys)
}
return pools;
};
Expand Down

0 comments on commit 01ac823

Please sign in to comment.