Pricing Strategies

Our pricing system can be broken down into two major components:

  • Pricing Discovery (asynchronous process)
  • Price Fetching (real-time)

When a token that hasn't been priced before is requested via the API (that is, a token address for a particular chain that the system hasn't priced before), it gets put into a discovery queue.

The discovery algorithm will find the best pricing solution depending on the strategy requested by the client. If, for example, the strategy requested is dexHighestLiquidity, then the discovery algorithm will iterate through all known DEXes and liquidity pools in that chain, until it finds the liquidity pool that satisfies that criteria.

Once a solution has been found for a particular token, subsequent requests to price that token will be processed in real-time.

We currently support the following pricing strategies:

DEX Highest Liquidity

This is the default strategy used if you don't pass one to the API. To request it explicitly, pass dexHighestLiquidity in the strategy parameter.

Note: when we say "highest liquidity", we mean so in USD terms.

For this strategy, we employ a recursive algorithm that will iterate through all pools where the token in question trades, and calculate the USD value of the total liquidity in that pool.

It is recursive because finding the USD price of the token in that pool might take multiple steps. For example:

Imagine that you're trying to price $MKR on Ethereum mainnet, and the highest liquidity pool happens to be MKR/ETH on Uniswap v3.

At that point, we can calculate the price of MKR in terms of ETH, but we still need to know the price of ETH in USD terms, to be able to report a final price in USD for MKR.

So we also find the highest liquidity pool of ETH (in this example) against a USD-pegged stablecoin, and also calculate that in the process.

In the end, you receive the price of MKR in USD terms.