> For the complete documentation index, see [llms.txt](https://docs.agnostic.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agnostic.dev/tutorials/uniswap-v3/definition.md).

# Definition

## The example

> Can we display a price curve of ETH/USDC projected from swap happening on-chain over time to thousands of users with the freshest data?

It shouldn't be an issue with a well-designed protocol like Uniswap and Agnostic powerful live aggregation and serving capabilities.

## The Uniswap V3 data model

Fortunately, Uniswap publishes many valuable Events, allowing us to track the protocol activity with our \`evm\_event\_\*\` data collection.\
\
Let's explore the [documentation](https://docs.uniswap.org/contracts/v3/reference/core/interfaces/pool/IUniswapV3PoolEvents) and find the Swap event signature; it's the one we are looking for here.

```solidity
event Swap(
  address sender,
  address recipient,
  int256 amount0,
  int256 amount1,
  uint160 sqrtPriceX96,
  uint128 liquidity,
  int24 tick
)
```

In this version of Uniswap, we have very interesting values: `sqrtPriceX96` and `tick`. In the previous versions, we had to calculate the price from the amounts directly. Let's try to look at the `tick`.

So, with this explanation from the documentation:

| Name                                    | Type                                   | Description                                                                              |
| --------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------- |
| `sender`                                | address                                | The address that initiated the swap call, and that received the callback                 |
| `recipient`                             | address                                | The address that received the output of the swap                                         |
| `amount0`                               | int256                                 | The delta of the token0 balance of the pool                                              |
| `amount1`                               | int256                                 | The delta of the token1 balance of the pool                                              |
| `sqrtPriceX96`                          | uint160                                | The sqrt(price) of the pool after the swap, as a Q64.96                                  |
| `liquidity`                             | uint128                                | The liquidity of the pool after the swap                                                 |
| <mark style="color:blue;">`tick`</mark> | <mark style="color:blue;">int24</mark> | <mark style="color:blue;">The log base 1.0001 of price of the pool after the swap</mark> |

We should be able to get the price with this simple formula:

```sql
pow(1.0001, tick)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.agnostic.dev/tutorials/uniswap-v3/definition.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
