---
# System prepended metadata

title: 'Maximum Allowable Collateral:'

---

# Maximum Allowable Collateral:

### Goal

- Offering the margin users with allowable collateral based on the Liquidation Ratio(Health Metric) calculation, prior to opening up a desired postion.
- Ensuring MTP security based on the ongoing status of pool depth.

### Proposed Mechanism:

Suppose,
The x-token pool depth = $X$
The y-token pool depth = $Y$
Fee numerator/Fee Denomerator =  $(1-f)$, where $f$ is fixed fee 0.3%. 
Liquidation Ratio =  $LR$
The maximum allowable collateral = $\Delta{x}$
Leverage Multiplier= $\eta$
Custody amount =  $y_C$
Principle Liability(Loan Amount) =  $x_L^P$



From the [LR Definition](https://github.com/Sifchain/issues/issues/1890#issuecomment-1205733652), we have:

 $$LR =\frac{y_C}{x^L_P}
      = \frac{y_C}{(\eta+1)\Delta{x}}$$$$=>LR(\eta+1)\Delta{x}=\frac{(1-f)*\Delta{y}*X}{\Delta{y}+Y}$$
      Now, for swap x_to_y the $\Delta y$ is input and can be substituted with the following fixed fee equation:
      $$ \Delta y = \frac{(1-f)(\eta+1).\Delta x. Y}{(\eta+1).\Delta x + X} 
      $$
So, the simplification after the substitution goes like following: 
$$
=>LR(\eta+1)\Delta{x}=\frac{\frac{(1-f).(1-f)(\eta +1).\Delta x.Y.X}{(\eta +1)\Delta x  + X}}{\frac{(1-f)(\eta+1)\Delta x.Y}{(\eta+1)\Delta x + X}+Y}
$$

$$=>LR(\eta+1)\Delta{x}= \frac{(1-f)^2(\eta+1)\Delta xY.X}{(1-f)(\eta +1)\Delta xY+(\eta +1)\Delta xY + XY} $$
Dividing out $\Delta x.(\eta+1).Y$ from the both side we get:

$$LR[(1-f)(\eta+1)\Delta x+(\eta+1)\Delta x+ X]=(1-f)^2X $$


$$=>\Delta x.LR[(1-f)(\eta+1)+(\eta+1)]=(1-f)^2X - LR.X$$

 
So, the final expression goes like this:
$$\Delta{x}= \frac{X[(1-fee)^2-LR]}{LR(2-f)(\eta+1)}$$

Here, $LR$ should be equal to the Safety Factor $SF$ parameter(has the value in the range [1.05,1.1]), $\eta$ is equal to the 9 to get a 10X leverage. f=0.3% or 0.003 fixed fee for swaps. $X$ and $Y$ represents the pool depth of the x and y token respectively.






