Skip to content

fix(indexer): align tradeParser's topic with the contract event convention#667

Merged
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
melopaul:fix/588-trade-event-topic-convention
Jun 30, 2026
Merged

fix(indexer): align tradeParser's topic with the contract event convention#667
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
melopaul:fix/588-trade-event-topic-convention

Conversation

@melopaul

Copy link
Copy Markdown

Summary

  • Every event currently published by contracts/market/src/events.rs follows the same pattern: Soroban's #[contractevent] macro snake-cases the event struct name including its literal Event suffixMarketCreatedEventmarket_created_event, MarketResolvedEventmarket_resolved_event, CollateralDepositedEventcollateral_deposited_event, etc. (confirmed against each event's own unit test in events.rs). tradeParser.ts's "trade_executed" discriminator was the one outlier still guessing the unsuffixed form — it's now "trade_executed_event", consistent with every other parser in this module after Fix resolutionParser for u32 bool u64 payload #589 and Wire market_created parser into ingestion loop #590.
  • Unlike Fix resolutionParser for u32 bool u64 payload #589/Wire market_created parser into ingestion loop #590, this isn't fixing a live ingestion bug: the contract doesn't publish a trade execution event yet (trades are currently matched off-chain by the CLOB — see the Trade/IndexedTrade Prisma models). This aligns the parser with the established naming convention now, so that whenever TradeExecutedEvent ships on-chain, it isn't silently dropped the same way market_created_event and market_resolved_event were before this round of fixes.

Why

Closing out the same class of topic-naming drift across all four indexer parsers for consistency, now that #589 and #590 established the real convention from the contract source.

Test plan

  • Updated apps/indexer/src/tradeParser.test.ts and apps/indexer/src/ingestion.test.ts's TRADE_TOPIC fixture to the corrected discriminator.
  • npx vitest run apps/indexer/src — all pass except 3 pre-existing, unrelated failures already present on dev (collateralDepositedParser.test.ts, storage.test.ts).
  • Updated docs/indexer-event-mapping.md and apps/indexer/fixtures/contract-event-vectors.json to document the corrected topic and note that this anticipates a not-yet-implemented on-chain event.

Closes #588

itodo001 and others added 2 commits June 29, 2026 00:22
…ntion

Every event currently published by contracts/market/src/events.rs
follows the same pattern: Soroban's #[contractevent] macro snake-cases
the event struct name including its literal "Event" suffix
(MarketCreatedEvent -> "market_created_event", MarketResolvedEvent ->
"market_resolved_event", CollateralDepositedEvent ->
"collateral_deposited_event", etc. — confirmed against each event's own
unit test in events.rs). tradeParser.ts's "trade_executed" discriminator
was the one outlier guessing the unsuffixed form.

The contract doesn't publish a trade execution event yet — trades are
currently matched off-chain by the CLOB (see the Trade/IndexedTrade
Prisma models and ingestion.ts's comments) — so this isn't fixing a
live ingestion bug the way Vatix-Protocol#589/Vatix-Protocol#590 were. It aligns the parser with
the established convention now, so that whenever TradeExecutedEvent
ships it isn't silently dropped the same way market_created and
market_resolved events were before this round of fixes.

Updated tradeParser.test.ts, ingestion.test.ts's TRADE_TOPIC fixture,
docs/indexer-event-mapping.md, and contract-event-vectors.json to the
corrected discriminator.

Closes Vatix-Protocol#588
@Mimah97 Mimah97 merged commit 5c797d1 into Vatix-Protocol:dev Jun 30, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align tradeParser with contract event shape

3 participants