> For the complete documentation index, see [llms.txt](https://docs.tapir.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tapir.money/protocol-mechanics/tapir-mechanics/oracle-resolution/vrp-oracle.md).

# VRP Oracle

VRP stands for **Vault Redeem Preview**.

Some protected assets are vault-based. For these assets, the normal pool price is not the whole story. Their value also depends on how much underlying asset the vault shares can redeem for.

The VRP Oracle checks whether those vault shares kept their redeemable value during the pool. It is an extension of the [base oracle](https://docs.tapir.money/protocol-mechanics/tapir-mechanics/oracle-resolution.md); its sibling for Pendle Principal Tokens is the [PTRW Oracle](https://docs.tapir.money/protocol-mechanics/tapir-mechanics/oracle-resolution/ptrw-oracle.md).

Important distinction:

```
The normal price-resolution part can use several price inputs.
The VRP part reads from one vault preview source, repeatedly over time.
```

***

## Where the VRP value comes from

The VRP Oracle reads the vault's own redeem preview.

In code, the value comes from:

```solidity
IERC4626(vault).previewRedeem(witnessShares)
```

Meaning:

| Term                 | Meaning                                                                   |
| -------------------- | ------------------------------------------------------------------------- |
| `vault`              | The vault being protected                                                 |
| `witnessShares`      | A fixed amount of vault shares used for all VRP checks                    |
| `previewRedeem(...)` | The vault's estimate of how much underlying asset those shares redeem for |

So the VRP value is not a market price. It is the vault's own answer to:

```
If these shares were redeemed, how much underlying asset should they return?
```

***

## Why vault redeem value matters

A vault token can look stable while the vault itself loses redeemable value.

Example:

```
Normal price: 1.00
Vault redeem value before: 2.00
Vault redeem value now:    1.00
```

Here the normal price is the feed for the vault's reference asset, before the VRP adjustment. It alone says that reference asset looks fine. The vault preview says something important changed.

This is why Tapir needs the VRP Oracle for vault-based assets.

***

## Why VRP observes over time

The VRP Oracle is allowed to rely on the vault's own preview. That is the point of VRP: it measures the vault's redeemable value directly.

The risk is timing. If Tapir only checked the vault once, at the exact end of the pool, users would be exposed to one abnormal reading.

Examples of what can go wrong:

| Risk                       | Example                                                                    |
| -------------------------- | -------------------------------------------------------------------------- |
| Temporary accounting issue | A vault briefly reports a lower redeem value because of a delayed update.  |
| One-off preview spike      | A preview value jumps for one observation, then returns to normal.         |
| One-off preview drop       | A preview value drops for one observation, then recovers.                  |
| Delayed protocol update    | The vault has not yet processed a reward, loss, or accounting change.      |
| Real vault loss            | The vault genuinely lost underlying value and each share redeems for less. |

The VRP Oracle compares the final vault preview against observations recorded over time. This helps separate short-term noise from a real change in redeemable value.

***

## Single-source risk

The VRP Oracle is intentionally specific: it asks the vault itself how much a fixed amount of shares should redeem for.

This is powerful because it measures the vault's internal redeemable value directly.

But it also creates an important risk:

```
If the vault preview is wrong, the VRP Oracle can also be wrong.
```

Examples:

| What goes wrong                   | Why it matters                                              |
| --------------------------------- | ----------------------------------------------------------- |
| The vault reports a wrong preview | Tapir may calculate too much or too little vault-value loss |
| The vault preview is stale        | Tapir may resolve from an old internal value                |
| The vault accounting is delayed   | A temporary mismatch may look like a drop in value          |
| The vault preview returns zero    | Automatic VRP resolution cannot safely continue             |
| The vault contract has a bug      | Tapir can inherit the wrong redeem-value signal             |

For VRP, there is no independent second vault inside the oracle to vote against the first one. The protection comes from:

* recording the same vault preview over time,
* ignoring short-lived spikes through the VRP high watermark,
* applying tolerance to small final differences,
* delaying final resolution after prices are submitted,
* and an admin-controlled backup or override for the final preview.

VRP makes vault-level loss visible, while still depending on the vault preview being a reliable signal.

***

## What the VRP Oracle records

When the VRP Oracle is deployed, it takes one snapshot:

```
initialVrpPreview = vault preview at deployment
```

This becomes the reference value. Every later vault preview is read as a ratio against this starting point. It does not change once the oracle is live.

After deployment, the VRP Oracle tracks a fixed amount of vault shares and repeatedly asks:

```
How much underlying asset would these shares redeem for?
```

Example with `initialVrpPreview = 2.00`:

```
Day 0 (deployment): 2.00   <- reference value
Day 1: 2.00
Day 2: 2.01
Day 3: 2.01
Day 4: 2.02
Day 5: 2.02
```

This creates a history of the vault's redeemable value, anchored to the deployment-time reference.

***

## VRP high watermark

The VRP high watermark is the strongest vault redeem value that was held in a robust way.

Tapir does not simply take the highest preview value. A single high value can be noise.

Instead, Tapir looks for the highest preview level that survived a multi-day window.

In plain terms:

```
VRP high watermark = the strongest vault redeem value that was held over time
```

Example:

```
Vault previews: [2.00, 3.00, 2.00, 2.00, 2.00]

The 3.00 value is only a one-day spike.
VRP high watermark: 2.00
```

The spike does not define the pool because it was not sustained.

The oracle groups previews by UTC day using the base oracle's daily rules, then takes the highest minimum over consecutive triplets of observed days. With fewer than three distinct UTC days, the buffered candidate is zero; the effective HWM remains anchored to the **deployment-time preview**, not the highest early observation.

The preview buffer holds 400 raw points. The effective HWM is the maximum of the current buffer candidate and `persistedVrpHwm`, which starts at the deployment preview and only increases. It preserves qualifying highs after old observations leave the buffer. Observed days need not be consecutive calendar days.

***

## Final preview value

`resolveVrp()` requires `OPERATOR_ROLE` and an unpaused oracle. It takes one more vault-preview reading; that single value becomes the final preview. The function has no pool-maturity check, so timing the call near settlement is an operational responsibility. A successful automated resolution cannot be repeated through that function.

This final preview is compared with the VRP high watermark.

| Result                                           | Meaning             |
| ------------------------------------------------ | ------------------- |
| Final preview is close to the VRP high watermark | Vault value held    |
| Final preview is below the VRP high watermark    | Vault value dropped |

Two protections sit around this single reading:

* **Error tolerance**, set at deployment as an absolute amount. Tiny differences can be ignored.
* **Resolution delay**, a waiting period after final prices are submitted. This gives Tapir and the community time to spot a clearly bad sample before the pool is resolved.

Example:

```
VRP high watermark: 2.00
Final preview:      1.98
Error tolerance:    0.02
Result: no vault-value reduction after tolerance
```

Example with a real drop:

```
VRP high watermark: 2.00
Final preview:      1.00
Error tolerance:    0.00
Result: 50% vault redeem-value drop
```

***

## How VRP affects resolution

VRP adjusts the final values submitted for pool resolution.

The normal high watermark and normal closing price are each multiplied by a VRP component:

```
adjusted HWM = min(MAX_PRICE, floor(normal HWM * VRP HWM / initial reference))
effective final preview = min(VRP HWM, final preview + tolerance)
adjusted closing = min(MAX_PRICE, floor(normal closing * effective final preview / initial reference))
```

The closing-price factor uses `final preview + tolerance`, capped at the VRP high watermark. Both adjusted prices are then capped independently at the pool's immutable `MAX_PRICE`. This avoids a submission failure when vault appreciation exceeds that ceiling, but can compress the measured gap. The price bounds need sufficient headroom for expected vault growth.

`writePriceData()` requires a resolved VRP value and a non-zero base-price HWM. VRP supports **same-chain delivery only**; enabling cross-chain mode is rejected.

When the vault is unchanged, both components equal 1 and nothing scales. When the vault has grown, both components scale up together, so there is no false depeg. When the vault has lost value, the closing component shrinks faster than the HWM component, and the gap registers as a depeg.

***

## Examples

These examples assume zero tolerance, adjusted prices below `MAX_PRICE`, and the stated base-oracle values.

### Vault value rises

This is the healthy case for a yield-bearing vault.

```
Normal HWM:          1.00
Normal closing:      1.00
Initial reference:   2.00
VRP high watermark:  3.00
Final preview:       3.00
```

Both VRP components are `3.00 / 2.00 = 1.50`.

```
Adjusted HWM:     1.00 * 1.50 = 1.50
Adjusted closing: 1.00 * 1.50 = 1.50
Result: no depeg
```

Vault growth flows through without triggering a false signal.

### Vault value drops

This is the main case the VRP Oracle is built for.

```
Normal HWM:          1.00
Normal closing:      1.00
Initial reference:   2.00
VRP high watermark:  2.00
Final preview:       1.00
```

The normal price did not depeg, but the vault shares now redeem for half as much underlying value.

```
Adjusted HWM:     1.00 * (2.00 / 2.00) = 1.00
Adjusted closing: 1.00 * (1.00 / 2.00) = 0.50
Result: 50% depeg
```

Tapir treats this as a depeg because the protected asset lost redeemable value.

### Normal price and vault value both drop

```
Normal HWM:          1.00
Normal closing:      0.80
Initial reference:   2.00
VRP high watermark:  2.00
Final preview:       1.00
```

The normal price fell by 20%, and the vault redeem value fell by 50%.

Tapir's final resolution reflects both effects.

***

## Manual fallback

If the vault is healthy, `previewRedeem` should return a sensible number. If the vault is in trouble, it can return zero.

If the final reading returns zero, `resolveVrp()` sets `forceManualResolve` and leaves VRP unresolved. If the vault call reverts, the transaction rolls back instead; it does not set that flag.

An account with `DEFAULT_ADMIN_ROLE` can call `manualBackupResolveVrp()` to supply a final preview, including zero. **This admin override does not require a prior failure or an unresolved VRP state** and can replace a previously recorded value. It is also callable while the oracle is paused.

An override affects pool settlement only if the operator can submit the resulting prices while the pool remains in Cooldown. It cannot change an already resolved pool. See [Source Code & Contracts](https://docs.tapir.money/resources/source-code-and-contracts.md) for the access-control references.

***

## In plain terms

For regular pegged assets, Tapir asks:

```
Did the asset hold its expected value?
```

For vault-based assets, the VRP Oracle also asks:

```
Did the vault shares keep their redeemable value?
```

That is the core idea behind the VRP Oracle.
