# Profit and Loss

## What is PnL

Profit and Loss, often abbreviated as PnL, in the context of providing liquidity, refers to the financial outcome that results from the difference in the value of tokens at two distinct points in time: the initial moment when the liquidity is added and the subsequent moment when the liquidity is removed.

### Actions

#### Adding Liquidity

In the process of [adding liquidity](https://docs.wingriders.com/actions/adding-liquidity), a user decides to deposit tokens to the [liquidity pool](https://docs.wingriders.com/glossary#liquidity-pool). Liquidity providers receive [LP tokens](https://docs.wingriders.com/glossary#liquidity-provider-token) (liquidity provider tokens) in return for locking in their tokens.

Deposited tokens are worth something, and based on that we calculate the <mark style="color:orange;">average value of received LP tokens</mark>. If you had LP tokens before, we blend the old and new averages and remember the all-time average.

#### Removing Liquidity

[Removing liquidity](https://docs.wingriders.com/actions/removing-liquidity) is a process of redeeming received LP tokens back into the deposited tokens. By doing this, the user receives back their portion of the tokens locked in the liquidity pool.

Received tokens have some value, and based on that we calculate the <mark style="color:orange;">average value of redeemed LP tokens</mark>.

### Realized PnL

Profit or loss of each removing liquidity action is the difference between <mark style="color:orange;">average value of received LP tokens</mark> and <mark style="color:orange;">average value of redeemed LP tokens</mark>. Realized PnL is the sum of these profits or losses.

### Unrealized PnL

Without actually removing liquidity, we calculate what would be your profit or loss if you removed all your liquidity. That is an unrealized PnL.

### More in-depth explanation

For each pool:

* For the user’s initial adding liquidity action, we use the value of deposited tokens (at the time of the deposit) and calculate the average cost of received LP tokens (by dividing value of deposited tokens by the number of received LP tokens). We then store the number of <mark style="color:orange;">received LP tokens</mark> and <mark style="color:orange;">average cost of LP tokens</mark>.
* For each subsequent adding liquidity action, we calculate the average cost of newly received LP tokens. Then we update the stored number of <mark style="color:orange;">received LP tokens</mark> and <mark style="color:orange;">average cost of LP tokens</mark> (by adding newly received LP tokens to the stored number of <mark style="color:orange;">received LP tokens</mark> and by multiplying the stored number of <mark style="color:orange;">received LP tokens</mark> and <mark style="color:orange;">average cost of LP tokens</mark>, adding value of deposited tokens, and dividing everything with updated number of <mark style="color:orange;">received LP tokens</mark>).
* For each removing liquidity action, cost of deposited LP tokens is the stored <mark style="color:orange;">average cost of LP tokens</mark> times the number of deposited LP tokens. Profit or loss for this action is the difference between the cost of deposited LP tokens and the value of received tokens (at the time of receiving). We update the number of <mark style="color:orange;">received LP tokens</mark> (by reducing the number of deposited LP tokens from the stored number of <mark style="color:orange;">received LP tokens</mark>).
* Realized PnL for each pool is the sum of PnL for each removing liquidity action.

Your total PnL is the sum of PnL of each pool.

## What impacts PnL

PnL in WingRiders liquidity pools is affected by everything that affects removing liquidity, which is explained in <https://docs.wingriders.com/actions/removing-liquidity>

It is important to note that the PnL calculation on WingRiders currently does not include the rewards earned from yield farming.


---

# Agent Instructions: 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:

```
GET https://docs.wingriders.com/portfolio/profit-and-loss.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
