> For the complete documentation index, see [llms.txt](https://docs.smoothy.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smoothy.finance/advance/virtual-price.md).

# Virtual Price

## Definition

Virtual price is defined as

*virtualPrice = totalAssetBalance / totalLpSupply*

where totalAssetBalance is the summation of all balances of underlying assets and totalLpSupply is the total supply of LP tokens.

**Example A (Virtual Price Calculation):** Suppose the pool has two stablecoins USDT/USDC with balances \[1M, 1M] and the total supply of syUSD (LP token) is 1.5M, then the virtual price is (1M + 1M) / 1.5M = 1.3333.

## Virtual Price as Exchange Rate

For any pool operations that converts LP token from/to underlying asset (e.g., mint syUSD with USDT or redeem syUSD for USDC), virtual price is essential the **exchange rate** between the LP token and underlying asset **if no penalty (e.g., slippage cost) happens**.

**Example B (Redeem without Penalty)**: Suppose the pool has two stablecoins USDT/USDC with balances \[1M, 1M], total supply of syUSD (LP token) is 1.5M, and soft weights are \[0.6, 0.6].  Redeeming **0.1M** **syUSD** for USDC will not incur a penalty (as the resulting percentages are \[0.5263, 0.47368]), and as a result, the pool will return **0.13333M** **USDC** for the redemption (virtual\_price = 1.3333).

**Example C (Redeem with Penalty):**  Suppose the pool has two stablecoins USDT/USDC with balances \[1M, 1M], total supply of syUSD (LP token) is 1.5M, and soft weights are \[0.6, 0.6].  Redeeming **0.5M** syUSD for USDC will incur a penalty (as the resulting percentages will exceed 0.6), and as a result, the pool will return **less than 0.6667M USDC** for the redemption (virtual\_price = 1.3333).

One common mistake in calculating virtual price is to use the exchange rate of a transaction as virtual price, which is incorrect if such a transaction incurs a penalty.

## Virtual Price Property

One key property of virtual price is that the value should **be non-decreasing** to reflect the accumulated interest + swap fee + penalty fee, i.e., the value of per LP token is self-value-accrued over time by earning interest + swap fee + penalty fee automatically.

**Example D (Virtual Price with Fee):** Suppose the pool has two stablecoins USDT/USDC with balances \[1M, 1M], total supply of syUSD (LP token) is 1.5M. Suppose a user swaps 0.1M USDT for 0.09M USDC, the resulting pool becomes \[1.1M, 0.91M], and thus the virtual price increases from 1.3333 to 1.34.

**Example F (Virtual Price with Interest)**: Suppose the pool has two stablecoins USDT/USDC with balances \[1M, 1M], total supply of syUSD (LP token) is 1.5M. After some time, the pool earns interests \[0.1M, 0.15M] respectively.  As a result, the virtual price increases from 1.3333 to 1.5.


---

# 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.smoothy.finance/advance/virtual-price.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.
