- Polling Swap events for all pairs
- Subscription using eth_subscribe (coming later - HIP-694)
Polling Swap Events for All Pairs
⛽ No gas cost Every time a user executes a swap, the contract emits a ‘Swap’ event with the updated reserve values for the token pair. The following code demonstrates how to listen to these ‘Swap’ events for all pairs using either the REST API or JSON RPC.When a swap involves multiple liquidity pairs, a successful smart contract call will emit multiple ‘Swap’ events. To determine the route used, as well as the initial input amount and the final output amount, aggregate all the ‘Swap’ event logs.
- JSON RPC
- REST API