Skip to content

Commit

Permalink
fix: Adapter, ChainGpt [Outdated] (#11153)
Browse files Browse the repository at this point in the history
Co-authored-by: 0xpeluche <[email protected]>
  • Loading branch information
0xpeluche and 0xpeluche authored Jul 30, 2024
1 parent 885785f commit a9f8bdc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions projects/chaingpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config = {
{ factory: '0x2D47310bB0C6A9D4ae2a1d6625eC0BEe4F473Bb6', fromBlock: 46082883 },
],
core: [
{ factory: '0x9840652DC04fb9db2C43853633f0F62BE6f00f98', fromBlock: 15191500 },
{ factory: '0x9840652DC04fb9db2C43853633f0F62BE6f00f98', fromBlock: 15191500, blacklistedTokens: ['0xcE87100A1dBAf576ebd063EB0890840346338689'] },
],
base: [
{ factory: '0xFB5cd8426FBC3b1f2ea4B113A5A37752B3098C79', fromBlock: 15137100 },
Expand All @@ -49,22 +49,29 @@ async function tvl(api) {
const chainConfigs = config[api.chain]
const ownerTokens = []
const poolTokenMapping = {}
let blacklistedTokens = []

for (const chainConfig of chainConfigs) {
const { factory, fromBlock } = chainConfig
const { factory, fromBlock, blacklistedTokens: configBlacklistedTokens } = chainConfig

if (configBlacklistedTokens) {
blacklistedTokens = blacklistedTokens.concat(configBlacklistedTokens)
}

const logs2 = await getLogs({
api,
target: factory,
eventAbi: 'event PresalePoolCreated (address registedBy, address indexed token, address indexed pool, uint256 poolId)',
fromBlock: fromBlock,

})

const pools = []
const poolFromBlocks = {}
logs2.forEach((i) => {
pools.push(i.args.pool)
poolFromBlocks[i.args.pool] = i.blockNumber
})

await PromisePool
.withConcurrency(7)
.for(pools)
Expand All @@ -79,6 +86,7 @@ async function tvl(api) {
})
logs.forEach(({ args: i }) => {
const key = i.token + '-' + i.owner

if (!poolTokenMapping[key]) poolTokenMapping[key] = []
poolTokenMapping[key].push(i.offeredCurrency)
})
Expand All @@ -91,7 +99,8 @@ async function tvl(api) {
ownerTokens.push([poolTokenMapping[key], i.pool])
})
}
return api.sumTokens({ ownerTokens })

return api.sumTokens({ ownerTokens, blacklistedTokens })

}

Expand Down

0 comments on commit a9f8bdc

Please sign in to comment.