Skip to content

Commit 23d486f

Browse files
committed
fix: deduplicate icm events
1 parent dcc6256 commit 23d486f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/icm-clickhouse.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,11 @@ export async function getICMStatsData(days: number): Promise<{
334334
let totalOutgoing = 0;
335335

336336
for (const [chainName, counts] of chains.entries()) {
337-
const mc = counts.incoming + counts.outgoing;
338-
chainBreakdown[chainName] = mc;
339-
totalMessageCount += mc;
337+
// Use only incoming (RECEIVE events) to avoid double-counting.
338+
// Each cross-chain message generates one SEND on the source chain and
339+
// one RECEIVE on the destination chain; counting both would double the total.
340+
chainBreakdown[chainName] = counts.incoming;
341+
totalMessageCount += counts.incoming;
340342
totalIncoming += counts.incoming;
341343
totalOutgoing += counts.outgoing;
342344
}
@@ -460,7 +462,8 @@ export async function getChainICMData(
460462
result.push({
461463
timestamp: dayToTimestamp(day),
462464
date: day,
463-
messageCount: counts.incoming + counts.outgoing,
465+
// Use only incoming (RECEIVE events) to deduplicate cross-chain messages.
466+
messageCount: counts.incoming,
464467
incomingCount: counts.incoming,
465468
outgoingCount: counts.outgoing,
466469
});

0 commit comments

Comments
 (0)