Skip to content

optimization: Batch event emissions for multi-hop trades #90

@AlAfiz

Description

@AlAfiz

Description

When a user executes a 3-hop trade (e.g., Asset A -> Asset B -> Asset C), our current logic emits a separate SwapEvent for every single hop.
Publishing multiple events to the Stellar ledger in a single transaction burns unnecessary gas and forces our indexer to reconstruct the final trade manually.
We need to aggregate the overall input and final output into a single, unified MultiHopSwap event.
This saves users money on ledger rent and simplifies our backend data architecture.

Requirements

  • Define a new event topic Symbol("MultiHopSwap").
  • In the swap_exact_tokens_for_tokens function, track the initial amount_in and the final amount_out.
  • Publish a single event at the very end of the routing loop instead of inside the loop.
  • Ensure the event payload includes the full Vec<Address> path that the trade took.

Metadata

Metadata

Assignees

Labels

Stellar 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