# Protocol Overview

The protocol is composed of two **ERC-4626 Vaults** (tranches): **Junior (Jrt)** and **Senior (Srt)**.\
Both vaults are implemented as *Meta Vaults*:

* Each has a **Base Asset**.
* They can also accept additional tokens supported by the underlying **Strategy**.
  * Example: the **Ethena USDe market** uses **USDe** as the Base Asset and also accepts **sUSDe.**

All vault shares are denominated in the **Base Asset**.\
User actions (`deposit`, `withdraw`, etc.) are forwarded to the **CDO contract** (the core orchestrator).

The **CDO contract** has two major components:

1. **Strategy**
2. **Accounting**

### Strategy

The Strategy contract is responsible for **asset management**. It receives assets from the CDO, stakes them, and must be able to return them when requested.

At any point in time, the Strategy reports its **total TVL** (incl. yield).

When returning assets, the Strategy uses different mechanisms:

* **Direct return**: Instant transfer to a Srt user e.g. `sUSDe` can be returned instantly to an Srt user.
* **ERC20 Cooldown (AssetsLock)**: Strategy locks tokens in a cooldown contract. Tokens can be withdrawn after the cooldown period.
* **Unstaking Cooldown**: Protocol-specific cooldown period for base assets. e.g. for USDe, the Strategy requests withdrawal from Ethena's `sUSDe`, which itself has a cooldown period.
* **Shares Cooldwon (SharesLock):** Strategy locks shares instead of tokens for a set period. After that, the user finalizes at the current exchange rate.
* **Fee:** Penalty for exiting

Each withdrawal request is handled independently per user. New requests do not extend or affect earlier requests.

### **Coverage-Aware Redemption Flow**

The protocol can split Senior Coverage into up to three ranges. For each range, the protocol can apply any combination of:

**1. SharesLock**

**2. AssetsLock**

**3. Fee**

These conditions can be used together or separately, depending on coverage. When coverage is low, exits become slower or more expensive, when coverage is high, exits become faster and cheaper.

The goal is to protect liquidity and discourage sudden outflow while keeping rules predictable.

### Accounting

The Accounting contract performs **pure calculations** for:

* `jrtTVL`
* `srtTVL`

From these, each vault derives its ERC-4626 `exchangeRate` and `totalAssets`.

#### Update Cycle

On every protocol action (`deposit`, `withdraw`), Accounting is updated:

1. Strategy reports current `totalTVL` at current block timestamp `t1`.
2. Accounting compares against the last saved `totalTVL` at `t0`.
3. **Strategy Gain** is calculated:

   `gain = totalTVL(t1) - totalTVL(t0)`

   (For `sUSDe`, this amount is always >= 0)
4. A portion of the gain may be redirected to **reserveTVL** (if the reserve percentage is set).
5. The remaining gain goes to Junior TVL.
6. Calculate Senior's desired gain and subtract from Junior's TVL.

#### Gain Splitting

**Senior Gain Desired (Target)**: Based on the Senior tranche's target index (APR target), last srtTVL and deltaT.

Two cases:

**Case A: Strategy Gain >= Senior Gain Desired**

* Seniors receive their full target.
* Juniors receive the remaining gain.
* So finally:

  `jrtTVL + srtTVL + reserveTVL == totalTVL`

**Case B: Strategy Gain < Senior Gain Desired**

* Any Senior APR shortfall is covered by the Junior tranche

#### Senior Gain Calculations

1. Generic APR calculation for period T0..T1 (Benchmark and Base)\
   `Grows_Factor = ExchangeRate_T1 / ExchangeRate_T0 - 1` \
   `APR = Grows_Factor / (T1-T0) * 1Year`
2. Senior APR calculation\
   `TVL_ratio_sr = TVL_sr / (TVL_sr + TVL_jr)` \
   `Risk_Premium = x + y * TVL_ratio_sr ^ k`\
   `APR_sr_v1 = APRtarget APR_sr_v2 = APRbase * (1 - Risk_Premium)`\
   `APR_sr = MAX(APR_sr_v1, APR_sr_v2)`
3. Senior Gain calculation for period T0..T1\
   `Interest_Factor = APR_sr * (T1-T0) / 1Year` \
   `Target_Index_T1 = Target_Index_T0 * (1 + Interest_Factor)`

   `Senior_Gain = TVL_sr * (Target_Index_T1 / Target_Index_T0 - 1)`

### Deposit Flow&#x20;

*(Example with Jrt)*

1. **Update Accounting**
   * Refresh Strategy TVL and calculate gains for the period `t0 → t1`.
   * Adjust Junior/Senior TVLs according to Gain Splitting rules.
2. **Calculate Shares (ERC-4626)**
   * `jrtTVL` is the vault's `totalAssets()`.
   * User's deposited assets are exchanged for shares proportional to current `jrtTVL`.
3. **Forward Assets to Strategy**
   * User's tokens are passed into the Strategy for staking.
   * `jrtTVL` is incremented accordingly.

### Withdrawals

Withdrawals follow the same process:

* First, Accounting updates TVLs at current block `t1`.
* Then, ERC-4626 `totalAssets()` is used to determine how many assets a user receives for redeeming shares.
* Strategy may return assets directly or via cooldown mechanisms, as described above.

### APRs Feed

The APR Feed contract provides dynamic parameters:

* **APR Benchmark**
* **APR Base**

Whenever these values change, the Feed updates the **Accounting contract**, which recalculates the **Senior Target Index** accordingly.

<figure><img src="/files/iEemyydYgMVRpBhCXP7T" alt=""><figcaption></figcaption></figure>


---

# 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.strata.markets/technical-documentation/protocol-overview.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.
