Developers > Perpetual Yield Tranches > Architecture
The main contract used by users is called
IdleCDOwhich allows depositing the underlying and mint tranche tokens (ERC-20), either AA or BB, and redeeming principal and interest from it.
The IdleCDO contract pools users' funds together and uses
IIdleCDOStrategyas a proxy for interacting with the underlying DeFi protocol to deposit funds and collect interest and rewards.
Governance tokens collected as rewards are not redistributed to users directly in the IdleCDO contract but rather sold to the market (
harvestmethod) and the underlying reinvested in the downstream lending provider where possible.
Other tokens, if any (e.g. IDLE that won't be sold or tokens that have no liquid markets) will get redistributed to people who staked their tranches in a
LiquidityGaugecontract usually one for AA and sometimes one for BB (for more info on Gauges, see here).
The codebase and a general overview of the architecture can be found at https://github.com/Idle-Labs/idle-tranches.
These are the core contracts used:
A contract that holds all the user pooled assets (both underlying, e.g. DAI, and interest-bearing tokens, e.g. idleDAI) and is an entry point for the user to mint tranche tokens and burn them to redeem principal and interest.
When users deposit into the CDO they will:
- update the global accounting of the system (i.e. split accrued rewards)
- mint their chosen tranche tokens.
Funds won't get put in lending right away.
harvestmethod will be called periodically to put new deposits in lending, get fees and update the accounting.
During the harvest call, some predefined rewards will be sold into the market (via Uniswap) and released linearly over x (currently set a 1500) blocks, to increase the value of all tranche holders. On redeem, users will burn their tranche tokens and get underlying using a checkpointed price (set at last harvest to avoid potential theft of interest, updated when dumping governance tokens to increase the tranche price).
On top of these, all the strategies (
IIdleCDOStrategy) currently used can be found here https://github.com/Idle-Labs/idle-tranches/tree/master/contracts/strategies.