Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Jun 28, 2024
1 parent 4a4f24b commit ece3385
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 76 deletions.
57 changes: 0 additions & 57 deletions projects/helper/kayakPoolTvl.js

This file was deleted.

38 changes: 19 additions & 19 deletions projects/kayak/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
const {tvl} = require('../helper/kayakPoolTvl'); // 确保路径正确
const { getLogs2 } = require('../helper/cache/getLogs')
const { sumTokens2 } = require('../helper/unwrapLPs')

const PoolAddress = {
avax_savax: "0x9173398180C86eB4A313F4e6EcdE24aDCaD9df34",
usdt_usdc: "0x385a1b97b5f887B3987992ad959698915D5519E4",
};

async function displayTVL() {
try {
const tvl1 = await tvl();
console.log("tvl1:",tvl1)
return {'USD': tvl1};
} catch (error) {
console.error('Error fetching TVL:', error);
}
const config = {
avax: { factory: '0x4df3038C2C7e13F46F0d63eC3AF5728F75Be3775', fromBlock: 46950081, }
}

module.exports = {
methodology: "Summary of the value of most locked assets denominated in USD. These assets are counted based on the number of tokens on the chain. For more details, please visit our official website: https://kayakfinance.io/.",
avax: {
tvl: displayTVL
Object.keys(config).forEach(chain => {
const { factory, fromBlock, } = config[chain]
module.exports[chain] = {
tvl: async (api) => {
const logs = await getLogs2({
api,
factory,
eventAbi: 'event NewStableSwapPair(address indexed swapContract, address indexed tokenA, address indexed tokenB)',
fromBlock,
})

const ownerTokens = logs.map(i => [[i.tokenA, i.tokenB], i.swapContract])
return sumTokens2({ api, ownerTokens })
}
};
}
})

0 comments on commit ece3385

Please sign in to comment.