Comment on page

Liquidation and Liquidity Theoretical

Enter Markets (Use fTokens as collateral)

We require users to specify whether they want to use a lent asset as liquidity for borrowing.

How does liquidity work?

Every open borrow is subject to be liquidated by a third party (that is, anyone) if the underlying value of the collateral locked in relation to the current value of the borrowed assets, falls under a certain level.
The following values are in the user's balances
collatUnderlyingMantissan=#fTokenSuppliednexchangeRateMantissancollateralFactorMantissamantissacollatUnderlyingMantissa_{n} = \\\frac{\#fTokenSupplied_{n}*exchangeRateMantissa_{n}*collateralFactorMantissa}{mantissa}

NOTE: fTokenSupplied_n references fTokens supplied in entered markets.

debtUnderlyingMantissan=#borrowedTokensInUnderlyingnmantissandebtUnderlyingMantissa_{n}= \#borrowedTokensInUnderlying_{n}*mantissa_{n}
Note the n subscript implies the specific token

totalCollatDollarMantissa

totalCollatDollarMantissa=i=1ncollatUnderlyingMantissandollarPerUnderlyingnunderlyingDecimalntotalCollatDollarMantissa =\\\sum_{i=1}^n\frac{collatUnderlyingMantissa_{n}*dollarPerUnderlying_{n}}{underlyingDecimal_{n}}

totalDebtDollarMantissa

totalDebtDollarMantisssa=i=1ndebtUnderlyingMantissandollarPerUnderlyingnunderlyingDecimalntotalDebtDollarMantisssa = \\\sum_{i=1}^{n}\frac{debtUnderlyingMantissa_{n}*dollarPerUnderlying_{n}}{underlyingDecimal_{n}}

Zero Liquidity Point

totalDebtDollarMantissa=totalCollatDollarMantissa\\totalDebtDollarMantissa =totalCollatDollarMantissa

Liquidation

Liquidation is a process in which one user repays the debt of the a borrower and essentially purchases some of the borrowers collateral at a discounted rate relative to the amount of repayment. On the Finterest protocol, we consider a user as underwater when they hit the liquidation point specified below:

Liquidation Point

liquidationPoint=(totalDebtDollarMantissa>liquidationThresholdMantissatotalCollatDollarMantissamantissa)liquidationPoint =\\(totalDebtDollarMantissa >\\\frac{liquidationThresholdMantissa*totalCollatDollarMantissa}{mantissa})
When you hit liquidation point, a user may repay your debt until:
totalDebtDollarMantissa<=liquidationThresholdMantissatotalCollatDollarMantissamantissatotalDebtDollarMantissa <=\\\frac{liquidationThresholdMantissa*totalCollatDollarMantissa}{mantissa}
Liquidation/Repayment of a borrower's debt happens on an individual token and not for all assets at once.

Discounted Collateral Purchase/Seizure

Let n = the token that is being borrowed and m = the token that the liquidator wants to seize from the borrower
amountRepayDollarMantissa=repayedAmountndollarPerUnderlyingnmantissaunderlyingTokenDecimalnamountRepayDollarMantissa=\\\frac{repayedAmount_{n}*dollarPerUnderlying_{n}*mantissa}{underlyingTokenDecimal_{n}}
collatSiezedDollarsMantissam=repaymentAmountndollarPerUnderlyingnliquidationDiscountMantissanunderlyingTokenDecimalncollatSiezedDollarsMantissa_{m}= \\\frac{repaymentAmount_{n}*dollarPerUnderlying_{n}*liquidationDiscountMantissa_{n}}{underlyingTokenDecimal_{n}}
collatSiezedfTokensm=repaymentAmountDollarsMantissamdecimalmdollarPerUnderlyingmexchangeRateMantissamcollatSiezedfTokens_{m} = \\\frac{repaymentAmountDollarsMantissa_{m}*decimal_{m}}{dollarPerUnderlying_{m}*exchangeRateMantissa_{m}}
A portion of seized collateral gets sent to the #Reserves and another portion to the liquidator
amountfTokensToReservesm=collatSeizedfTokensmprotocolSeizeSharemmantissaamountfTokensToReserves_{m}= \\\frac{collatSeizedfTokens_{m}*protocolSeizeShare_{m}}{mantissa}
amountfTokensToLiquidatorm=collatSeizedfTokensmamountfTokensToReservesmamountfTokensToLiquidator_{m}=\\collatSeizedfTokens _{m}-amountfTokensToReserves_{m}

Liquidation Checks

  1. 1.
    NOTE:
repayedAmountn=min[(closeFactorMantissanborrowBalanceBorrowern/mantissa),specifiedAmountn]repayedAmount_{n} =\\ min[(closeFactorMantissa_{n}*borrowBalanceBorrower_{n}/mantissa)\\,specifiedAmount_{n}]
Only the amount repaid will be taken from your balance so rest assured you are not being charged anymore than whats repaid.
  1. 2.
    Borrower hit liquidation point
  2. 3.
amoutRepayDollarMantissa<=(totalDebtDollarMantissaliquidationThresholdMantissatotalCollatDollarMantissamantissa)amoutRepayDollarMantissa <=\\(totalDebtDollarMantissa\\-\frac{liquidationThresholdMantissa*totalCollatDollarMantissa}{mantissa})
  1. 4.
collatSiezedfTokensn<=fTokenCollatBalanceBorrowerncollatSiezedfTokens_{n} <=fTokenCollatBalanceBorrower_{n}