Skip to content

Commit 5305654

Browse files
committed
update exclusion, move helper func
1 parent 0c134d0 commit 5305654

File tree

4 files changed

+60
-35
lines changed

4 files changed

+60
-35
lines changed

src/adaptors/frax/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const utils = require('../utils');
44

55
const { farmAbi, pairAbi } = require('./abi');
66
const { vstFraxStaking } = require('./vstFraxStaking');
7-
const { getERC4626Info } = require('../helpers/erc4626');
7+
const { getERC4626Info } = require('../../helper/erc4626');
88

99
const FRAXSWAP_POOLS_URL = 'https://api.frax.finance/v2/fraxswap/pools';
1010
const STAKING_URL = 'https://api.frax.finance/v1/pools';

src/adaptors/helpers/erc4626.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/helper/erc4626.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const sdk = require('@defillama/sdk');
2+
const utils = require('../adaptors/utils');
3+
4+
const DAY = 24 * 3600;
5+
6+
async function getERC4626Info(
7+
address,
8+
chain,
9+
timestamp = Math.floor(Date.now() / 1e3),
10+
{
11+
assetUnit = '100000000000000000',
12+
totalAssetsAbi = 'uint:totalAssets',
13+
convertToAssetsAbi = 'function convertToAssets(uint256 shares) external view returns (uint256)',
14+
} = {}
15+
) {
16+
const [blockNow, blockYesterday] = await Promise.all(
17+
[timestamp, timestamp - DAY].map((time) =>
18+
utils
19+
.getData(`https://coins.llama.fi/block/${chain}/${time}`)
20+
.then((r) => r.height)
21+
)
22+
);
23+
const [tvl, priceNow, priceYesterday] = await Promise.all([
24+
sdk.api.abi.call({
25+
target: address,
26+
block: blockNow,
27+
abi: totalAssetsAbi,
28+
}),
29+
sdk.api.abi.call({
30+
target: address,
31+
block: blockNow,
32+
abi: convertToAssetsAbi,
33+
params: [assetUnit],
34+
}),
35+
sdk.api.abi.call({
36+
target: address,
37+
block: blockYesterday,
38+
abi: convertToAssetsAbi,
39+
params: [assetUnit],
40+
}),
41+
]);
42+
const apy = (priceNow.output / priceYesterday.output) ** 365 * 100 - 100;
43+
return {
44+
pool: address,
45+
chain: utils.formatChain(chain),
46+
tvl: tvl.output,
47+
apyBase: apy,
48+
};
49+
}
50+
51+
module.exports = {
52+
getERC4626Info,
53+
};

src/utils/exclude.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ const excludeAdaptors = [
120120
'agave',
121121
'blueshift',
122122
'index-coop',
123+
'gyroscope-protocol',
124+
'blue-planet',
125+
'archimedes-finance',
126+
'koi-finance-amm',
127+
'kagla-finance',
128+
'plenty',
123129
];
124130

125131
const excludePools = [

0 commit comments

Comments
 (0)