Author: https://twitter.com/lowjiansheng

Objective: Build an application that fetches and processes on-chain Uniswap V3 data.

Background:

At Messari, we want to give our users a comprehensive view over the DeFi landscape. Unfortunately there’s currently no great source of DeFi data that provides the level of breadth and depth that we require. Therefore, we need to fetch these data on-chain across DeFi protocols and derive meaningful metrics from them.

Uniswap is the dominant decentralized exchange (Dex) on the Ethereum network. Users of Uniswap are able to swap and trade their tokens in a decentralized manner without any middleman. The way Uniswap works is through a concept called liquidity pools. In the case of Uniswap, a liquidity pool is made up of two tokens. Liquidity Providers provide liquidity into these pools by depositing an equal value amount of both tokens into the pool.

Liquidity providers earn an income (yield) from the pool that they have provided liquidity into through trade fees. When a swap happens on a liquidity pool, a small portion of the swap volume is given to liquidity providers as trading fees. For more information about how Uniswap works, you can check out the FAQ here.

In this challenge, we will be using Subgraphs from The Graph to pull on-chain data from Uniswap V3.

Uniswap V3 Playground link: https://thegraph.com/hosted-service/subgraph/ianlapham/uniswap-v3-subgraph

Uniswap V3 HTTP endpoint: https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-subgraph

Details of the challenge:

Where is the profit?

Let us figure out which liquidity pool on Uniswap V3 was the most profitable in a given timeframe. This is a helpful analysis that a lot of DeFi enthusiasts would like to know.

Your challenge, should you accept, is to integrate with the Uniswap V3 Subgraph (see links above), retrieve its liquidity, and determine which pool earned liquidity providers the most amount of money in USD for a given timeframe.