Index

How it works?

To get up-to-date prices market prices, we need to constantly listen to market updates. Fortunately, most DEX's provide a simple way to do that - using Ethereum events.

We introduced a service called Index to monitor this events and convert raw blockchain data into markets and tokens. It's now for internal use only, but later can become public.

For example: when swap occurs on uniswap v2, this event is emitted:

event Sync(uint112 reserve0, uint112 reserve1);

Index service takes this event, loads tokens at event's address and creates an entry in database:

{
    "address": "...",
    "token0": "...",
    "token1": "...",
    "reserve0": "...",
    "reserve1": "...",
    "blockNumber": "...",
    "chainId": "..."
    // ...
}

Later, those markets and tokens are loaded by routing service.

Last updated