# CDPs

Collateralized Debt Position
This documentation is a work in progress!
A collateralized debt position (CDP) is a system introduced by MakerDAO team with their decentralized stablecoin DAI.
Generally speaking it is a overcollateralized lending contract where borrowers deposit collateral and borrow assets against the deposited collateral. The contract itself acts as a counterparty when borrowers open a debt position.
Borrowers using these CDP's cannot withdraw their collateral if it takes the CDP below the minimum collateralization ratio set in the contract.

### CDPs Act As Cross Positions

One or more collaterals back each CDP and borrowers can take multiple debt positions on a single CDP. However, on the Kresko protocol borrowers can only have a single CDP per account.
CDPs in the Kresko synthetic asset protocol effectively act as cross-margined positions with many-to-many collateralization as opposed to 1-to-1 positions commonly referred to as having isolated margin.

### CDP Example

Example
• Collateral DAI has a cFactor of 1. Oracle price $1 • Collateral wBTC has a cFactor of 0.8. Oracle price$15000
• krAsset krETH has a krFactor of 1.1. Oracle price $1000 • krAsset krQQQ has a krFactor of 1. Oracle price$200
• Protocol MCR is 140%
Bob deposits 1500 DAI and 0.1 wBTC as collateral
Calculating the deposit values
1. 1.
DAI: $1500 * 1 =$1500
2. 2.
wBTC: $150 * 0.8 =$120
Bob's total collateral value is $1620 Bob sends a transaction to mint 1 krETH Calculating the debt value 1. 1. krETH:$1000 * 1.1 = $1100 Total collateral Bob needs to cover this mint:$1100 * 140% = $1540 As$1540 is less than $1620. Bob is a able to mint 1 krETH Bob wants to mint 1 krQQQ Calculating the debt value 1. 1. krQQQ:$200 * 1 = $200 Total collateral value Bob needs to cover this mint: ($1100 + $200) * 140% =$1820
We can see that Bob has insufficient collateral ($1620) to cover the mint so the transaction would fail. ## Overcollateralization In simple terms this means that for any amount of Kresko Asset to exist it must be backed by a Collateral Asset deposit of equal or greater value. In practice it is a bit more complicated: The protocol needs to eliminate the risk of any user ending up with a Collateral Asset deposit value less than their Kresko Asset debt value. To accomplish this, protocol needs to have a buffer. This buffer consists of multiple variables within the CDP like the MCR and krFactor. ## Collateralization Ratio Collateralization Ratio (CR) for an account is obtained by dividing the combined collateral value V with outstanding combined debt value D. $CR = \frac{V}{D}$ If Alice’s total deposit value is$4,806.46 and her total debt is \$1,278, then her collateral ratio is
$CR = \frac{\4,806.46} {\1,278} = 3.7609 = 376.09\%$

### Minimum Collateralization Ratio

Main safety buffer in a CDP is the Minimum Collateralization Ratio or MCR for short. It is the minimum collateralization ratio that allows for taking on debt.
If a CDP's collateralization ratio is under the MCR It does not mean it can be liquidated.
$(cValue_0 + ...+ cValue_n) * MCR$