- 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