This guide will illustrate how to fetch data from the SDK and details on instances where the SDK needs on-chain data and elobrates on strategies that you can use to fetch data.
For the SDK to perform queries and actions, it needs data in the format it can work with. For example, for a token, it requires the chainId, address and its decimals.
- the token address should be a manual input. Refer to this section for some popular token addresses
- the SDK can then look up other token related information via Fetcher.fetchTokenData
The best way to get all pools for a specific token pair is to call getPools on the factory, then selecting one of the pools from the returned array. If none exists, an empty array is returned.
- requires an on-chain lookup.
- the returned array of multiple pools will be indexed by first-come-first-address. In other words, pools created earlier will have lower index values.
Additionally, you can call the function getUnamplifiedPool on the factory, which returns pool with amplification factor = 1.
As an example, let's try to get data for the USDC-DAI pair.
Note that these values can change as frequently as every block, and should be kept up-to-date.