Skip to content

Commit

Permalink
Merge pull request #246 from dappradar/ferro-fix
Browse files Browse the repository at this point in the history
ferro fix
  • Loading branch information
mantasfam authored Jan 26, 2024
2 parents 8d2a5cc + feb36a4 commit f276f66
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/factory/providers/cronos/ferro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const START_BLOCK = 2539442;
const SWAP_DEPLOYER = '0xc4106bba1a8752e54940be71f7bd02c38e64f9e3';
const TOPIC =
'0x0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d9';
const LOGS_BATCH_SIZE = 10000;
const CHUNK_SIZE = 2;
const LOGS_BATCH_SIZE = 1000;
const CHUNK_SIZE = 5;

async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
const { block, chain, provider, web3 } = params;
Expand All @@ -34,33 +34,35 @@ async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
{ type: 'address[]', name: 'pooledTokens' },
];

try {
const decodedLogsParameters = await util.getDecodedLogsParameters(
cache.start,
block,
TOPIC,
SWAP_DEPLOYER,
undefined,
typesArray,
web3,
LOGS_BATCH_SIZE,
CHUNK_SIZE,
);
decodedLogsParameters.forEach((decodedLogParameters) => {
cache.pools.push({
swapAddress: decodedLogParameters.swapAddress,
pooledTokens: decodedLogParameters.pooledTokens,
if (cache.start < block) {
try {
const decodedLogsParameters = await util.getDecodedLogsParameters(
cache.start,
block,
TOPIC,
SWAP_DEPLOYER,
undefined,
typesArray,
web3,
LOGS_BATCH_SIZE,
CHUNK_SIZE,
);
decodedLogsParameters.forEach((decodedLogParameters) => {
cache.pools.push({
swapAddress: decodedLogParameters.swapAddress,
pooledTokens: decodedLogParameters.pooledTokens,
});
});
cache.start = block + 1;
await basicUtil.saveIntoCache(cache, 'cache/cache.json', chain, provider);
} catch (e) {
log.error({
message: e?.message || '',
stack: e?.stack || '',
detail: `Error: tvl of cronos/ferro. New logs are not scanned`,
endpoint: 'tvl',
});
});
cache.start = block + 1;
await basicUtil.saveIntoCache(cache, 'cache/cache.json', chain, provider);
} catch (e) {
log.error({
message: e?.message || '',
stack: e?.stack || '',
detail: `Error: tvl of cronos/ferro. New logs are not scanned`,
endpoint: 'tvl',
});
}
}

for (const pool of cache.pools) {
Expand Down

0 comments on commit f276f66

Please sign in to comment.