Skip to content

#6. Implement SO4 Soroban Event Mappings #183

Description

@IbrahimIjai

Primary outcome: The indexer decodes SO4 Soroban contract events and keeps GraphQL entities in sync with protocol state transitions.

Background

The contracts emit short symbol topics and tuple payloads. Important events include mkt_new, dep_crt, dep_exe, dep_can, wth_crt, wth_exe, wth_can, ord_crt, ord_exe, ord_can, ord_upd, ord_frz, pos_inc, pos_dec, liq_req, liq_exe, adl_req, adl_exe, fee_clm, fnd_clm, ui_fee_acc, ui_fee_clm, ui_fee_set, ref_reg, ref_set, ref_xfr, token events, and faucet events.

Implementation checklist

  • Replace the starter transfer-only handleEvent mapping with SO4 event dispatch.
  • Add decoding helpers for symbol topics.
  • Add decoding helpers for Soroban addresses.
  • Add decoding helpers for BytesN<32> keys.
  • Add decoding helpers for booleans.
  • Add decoding helpers for signed and unsigned integer ScVal values.
  • Add decoding helpers for tuple payloads emitted by SO4 contracts.
  • Restrict handlers to configured SO4 contract IDs and token IDs from Issue 2.
  • Implement mkt_new indexing from market_factory.
  • Implement deposit lifecycle mappings for dep_crt, dep_exe, and dep_can.
  • Implement withdrawal lifecycle mappings for wth_crt, wth_exe, and wth_can.
  • Implement order lifecycle mappings for ord_crt, ord_exe, ord_can, ord_upd, and ord_frz.
  • Implement position lifecycle mappings for pos_inc and pos_dec.
  • Implement liquidation mappings for liq_req and liq_exe.
  • Implement ADL mappings for adl_req and adl_exe.
  • Implement fee mappings for fee_clm, fnd_clm, ui_fee_acc, ui_fee_clm, and ui_fee_set.
  • Implement referral mappings for ref_reg, ref_set, and ref_xfr.
  • Implement token/faucet mappings for transfers, mints, burns, approvals, and claims where useful to the app.
  • Make entity writes idempotent so reprocessing a ledger does not duplicate rows.
  • Store ledger, timestamp, event id, contract id, and transaction hash if SubQuery exposes them.
  • Log and skip unknown events without crashing the indexer.

Acceptance checklist

  • Mappings build under Bun.
  • Unit tests cover at least one market event.
  • Unit tests cover at least one deposit event.
  • Unit tests cover at least one withdrawal event.
  • Unit tests cover at least one order event.
  • Unit tests cover at least one position event.
  • Unit tests cover at least one liquidation or ADL event.
  • Unit tests cover at least one fee or referral event.
  • Unit tests cover at least one token or faucet event.
  • Unknown or malformed events are handled safely with structured logs.
  • Entity IDs are deterministic and documented.

Verification commands

  • Run bun run --cwd apps/s03-indexer codegen.
  • Run bun run --cwd apps/s03-indexer build.
  • Run bun run --cwd apps/s03-indexer test.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignStellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions