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=mantissa#fTokenSuppliedn∗exchangeRateMantissan∗collateralFactorMantissa NOTE: fTokenSupplied_n references fTokens supplied in entered markets.
debtUnderlyingMantissan=#borrowedTokensInUnderlyingn∗mantissan Note the n subscript implies the specific token
totalCollatDollarMantissa
totalCollatDollarMantissa=i=1∑nunderlyingDecimalncollatUnderlyingMantissan∗dollarPerUnderlyingn totalDebtDollarMantissa
totalDebtDollarMantisssa=i=1∑nunderlyingDecimalndebtUnderlyingMantissan∗dollarPerUnderlyingn Zero Liquidity Point
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 Finny protocol, we consider a user as underwater when they hit the liquidation point specified below:
Liquidation Point
liquidationPoint=(totalDebtDollarMantissa>mantissaliquidationThresholdMantissa∗totalCollatDollarMantissa) When you hit liquidation point, a user may repay your debt until:
totalDebtDollarMantissa<=mantissaliquidationThresholdMantissa∗totalCollatDollarMantissa 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=underlyingTokenDecimalnrepayedAmountn∗dollarPerUnderlyingn∗mantissa collatSiezedDollarsMantissam=underlyingTokenDecimalnrepaymentAmountn∗dollarPerUnderlyingn∗liquidationDiscountMantissan collatSiezedfTokensm=dollarPerUnderlyingm∗exchangeRateMantissamrepaymentAmountDollarsMantissam∗decimalm A portion of seized collateral gets sent to the #Reserves and another portion to the liquidator
amountfTokensToReservesm=mantissacollatSeizedfTokensm∗protocolSeizeSharem amountfTokensToLiquidatorm=collatSeizedfTokensm−amountfTokensToReservesm Liquidation Checks
repayedAmountn=min[(closeFactorMantissan∗borrowBalanceBorrowern/mantissa),specifiedAmountn] Only the amount repaid will be taken from your balance so rest assured you are not being charged anymore than whats repaid.
Borrower hit liquidation point
amoutRepayDollarMantissa<=(totalDebtDollarMantissa−mantissaliquidationThresholdMantissa∗totalCollatDollarMantissa)
collatSiezedfTokensn<=fTokenCollatBalanceBorrowern