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 Strategy 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:
- Strategy
- Accounting
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: e.g.
sUSDecan be returned instantly to an Srt user. - ERC20 Cooldown: Strategy locks tokens in a cooldown contract. Tokens can be finalized/withdrawn after the cooldown period.
- Unstaking Cooldown: e.g. for USDe, the Strategy requests withdrawal from Ethena's
sUSDe, which itself has a cooldown period.
Each withdrawal request is handled independently per user. New requests do not extend or affect earlier requests.
The Accounting contract performs pure calculations for:
jrtTVLsrtTVL
From these, each vault derives its ERC-4626 exchangeRate and totalAssets.
On every protocol action (deposit, withdrawal), Accounting is updated:
-
Strategy reports current
totalTVLat current block timestampt1. -
Accounting compares against the last saved
totalTVLatt0. -
Strategy Gain is calculated:
gain = totalTVL(t1) - totalTVL(t0)(For
sUSDe, this amount is always >= 0) -
A portion of the gain may be redirected to reserveTVL (if the reserve percentage is set).
-
The remaining gain goes to Junior TVL.
-
Calculate Senior's desired gain and subtract from Junior's TVL.
- 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
-
Update Accounting
- Refresh Strategy TVL and calculate gains for the period
t0 → t1. - Adjust Junior/Senior TVLs according to Gain Splitting rules.
- Refresh Strategy TVL and calculate gains for the period
-
Calculate Shares (ERC-4626)
jrtTVLis the vault'stotalAssets().- User's deposited assets are exchanged for shares proportional to current
jrtTVL.
-
Forward Assets to Strategy
- User's tokens are passed into the Strategy for staking.
jrtTVLis incremented accordingly.
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.
The APR Feed contract provides dynamic parameters:
- APR Target (base rate)
- APR Base
Whenever these values change, the Feed updates the Accounting contract, which recalculates the Senior Target Index accordingly.
npm i
npm run compile
# OR in watch mode
npm run watch
npm run test
# OR single file
npx atma test ./test/tranches/ERC4626.spec.ts
# OR single file in watch mode
npx atma test ./test/tranches/ERC4626.spec.ts --watchTo localhost:
# start hh node
npm run node
# deploy/check unchanged
npm run deploy-local
(c) 2025