Skip to content

Commit

Permalink
fix: merkl api update (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec authored Jan 2, 2024
1 parent 1e48d66 commit b8a4ca1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/adaptors/merkl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const networks = {
137: 'polygon',
10: 'optimism',
42161: 'arbitrum',
1101: 'polygonzkevm',
8453: 'base',
};

async function getRateAngle(token) {
Expand All @@ -22,12 +24,13 @@ const main = async () => {
try {
data = await utils.getData('https://api.angle.money/v2/merkl');
} catch (err) {
console.log('no data for Merk');
console.log('no data for Merkl');
}

const project = 'merkl';

for (const chainId of Object.keys(data)) {
console.log(chainId);
const pools = data[chainId].pools;
for (const pool in pools) {
const poolAddress = pool;
Expand Down Expand Up @@ -57,7 +60,7 @@ const main = async () => {
const tvlUsd = pools[poolAddress].tvl;

// Trying to fetch tvl on-chain: query balances of the pool and price of both tokens

/*¨
const amountUsdOnChain0 = (
await sdk.api.abi.call({
target: underlyingTokens[0],
Expand Down Expand Up @@ -105,14 +108,15 @@ const main = async () => {
const tvlUsdOnChain =
(amountUsdOnChain0 / 10 ** decimalsToken0) * priceToken0 +
(amountUsdOnChain1 / 10 ** decimalsToken1) * priceToken1;
*/

const rewardToken = [];
liveDistributionsData.forEach((element) => {
rewardToken.push(element.rewardToken);
});
const apyReward = pools[poolAddress].meanAPR;

if (apyReward && apyReward > 0) {
if (apyReward && apyReward > 0 && tvlUsd && tvlUsd > 0 && chain) {
const poolData = {
pool: poolAddress,
chain: chain,
Expand All @@ -126,13 +130,12 @@ const main = async () => {
poolsData.push(poolData);
}
} catch {}
//console.log(poolsData);
} else {
continue;
}
}
return poolsData.filter((p) => utils.keepFinite(p));
}
return poolsData.filter((p) => utils.keepFinite(p));
};

/*
Expand Down

0 comments on commit b8a4ca1

Please sign in to comment.