# Free Collateral

The free collateral calculation calculation is a two part process.
1. 1.
Collect local currency collateral surplus/requirement figures for each supported currency
2. 2.
Aggregate local currency collateral figures into one ETH-denominated free collateral figure

### Local Currency Collateral Calculation

An account has four possible types of assets per currency: cTokens, nTokens fCash, and Liquidity Tokens. Calculating local currency collateral figures requires converting the value of these assets to a common denominator - local currency - applying relevant haircuts, and then summing the values together. Here is a step by step walk-through of this process.

#### Example Account Holdings in Local Currency

cTokens: +100 nTokens: +100
 Maturity fCash Liquidity Tokens June 1 2021 +100 0 September 1 2021 -50 +150 March 1 2022 -150 0

### Step 1: Decompose Liquidity Tokens into Claims on cTokens and fCash

Liquidity tokens are freely exchangeable for their constituent cTokens and fCash. The first step in this calculation is to aggregate these claims with the account's cTokens and fCash holdings. ### Step 2: Apply Liquidity Token Haircut to cToken and fCash Claims

Liquidity Tokens are risk assets because their net value can decrease. To account for this risk, we apply a haircut to the claims on cTokens and fCash derived from liquidity tokens for the purposes of calculating their value as collateral. The liquidity token haircut will be unique to each active tenor and will reflect the fact that longer dated liquidity tokens are riskier than shorter dated liquidity tokens. ### Step 3: Merge Liquidity Token Claims

Add the liquidity token claims on cTokens and fCash to the account's cToken balance and fCash ladder.
cTokens: +220 nTokens: +100
 Maturity fCash June 1 2021 +100 September 1 2021 +70 March 1 2022 -150

### Step 4: Get Present Value of fCash and Apply Haircut/Buffer

We get the present value of fCash by discounting the face value of that fCash to the present via the oracle rate which corresponds to the fCash asset's maturity. See more detail on this here. In order to account for the riskiness of fCash (the likelihood that its present value decreases) we adjust the oracle rate used to discount the face value of the fCash back to the present.
If the face value of the fCash is positive we adjust the oracle rate higher, such that the collateral value of the fCash is diminished. If the face value is negative, we adjust the oracle rate lower such that the collateral value of the debt is magnified in this calculation.
$if \text{ } fCash > 0: adjustedOracleRate = oracleRate + fCashHaircut \\~\\ if\text{ } fCash < 0: adjustedOracleRate = oracleRate - fCashBuffer \\~\\ collateralValue(fCash) = fCash * e^{-adjustedOracleRate \text{ }* \text{ } timeToMaturity}$
cTokens: +220 nTokens: +100
 Maturity fCash Collateral Value June 1 2021 +85 September 1 2021 +52 March 1 2022 -140

### Step 5: Get Present Value of nTokens and Apply Haircut

To get the collateral value of an account's nToken holdings, we first need to get the present value of a single nToken. The present value of one nToken is equal to the present value of all the assets in the nToken account (ignoring any haircuts) divided by the total supply of nTokens.
$PV(nToken) = PV(nTokenAccount) / nTokenSupply$
The present value of an account's nTokens is then just the present value of one nToken multiplied by the account's nToken balance.
$PV(nTokens) = PV(nToken) * nTokenBalance$
To get a collateral value for an account's nTokens we apply a haircut after getting the present value of their nTokens. Applying the haircut after the present value calculation is more practical than deriving a present value of their nTokens that includes haircuts on the constituent fCash and liquidity tokens in the nToken account.
$collateralValue(nTokens) = PV(nTokens) * nTokenHaircut$
cTokens: +220 nToken Collateral Value: +800
 Maturity fCash Collateral Value June 1 2021 +85 September 1 2021 +52 March 1 2022 -140

### Step 6: Convert cToken Value to Local Currency

$localCurrencycTokenValue = cTokenBalance * cTokenExchangeRate$
cToken Collateral Value: +2200 nToken Collateral Value: +800
 Maturity fCash Collateral Value June 1 2021 +85 September 1 2021 +52 March 1 2022 -140

### Step 7: Sum cToken Value with Collateral Values of nTokens and fCash

$localCurrencycTokenValue + collateralValue(nTokens) + collateralValue(fCash) \\~\\localCurrencyCollateral = 2200 + 800 + 85 + 52 - 140 \\~\\ localCurrencyCollateral = 2997$

### Aggregating Local Currency Collateral Values

Once we have local currency collateral values for each supported currency we aggregate them into a single ETH-denominated free collateral figure.

#### Exchange Rate Haircuts/Buffers

Notional allows users to hold collateral in one currency against debts in another currency. This introduces exchange rate risk. To account for this risk, we adjust the local currency collateral figure by either a buffer or a haircut when we convert it to ETH. We use a haircut (value less than 1) if the local currency figure is positive and a buffer (value greater than 1) if the figure is negative. Each currency type has its own haircut and buffer for use in this calculation.

### Step 1: Convert Local Currency Collateral Values to ETH

$if \text{ } localCurrencyCollateral > 0 \\~\\ ethDenominatedCollateral = localCurrencyCollateral * exchangeRate * haircut \\ ~ \\ if \text{ } localCurrencyCollateral < 0 \\~\\ ethDenominatedCollateral = localCurrencyCollateral * exchangeRate * buffer$
 Currency ETH DAI USDC Local Currency Collateral +1 +140 -100
$ETH/DAI \text{ } exchange Rate = 400 \\ETH/USDC \text{ } exchangeRate = 400 \\ ETH \text{ }Haircut = .8 \\ DAI \text{ }Haircut = .8 \\ USDC \text{ }Buffer = 1.25$
 Currency ETH DAI USDC Local Currency Collateral +1 +140 -100 ETH-Denominated Collateral +.8 +.28 -.3125

### Step 2: Sum ETH Denominated Collateral Values

$FreeCollateral = sum(EthDenominatedCollateral) \\~\\ FreeCollateral = .8 + .28 - .3125 \\ ~ \\ FreeCollateral = +.7675 \text{ } ETH$