kopi.money
  • Welcome
  • Introduction
    • The Kopi Money Market
    • What is a crypto wallet
    • What is a DEX?
    • Strategies to maximize earnings
    • Tokenomics
  • Using Kopi
    • Connect your wallet
  • How to trade
  • How to place orders
  • Using arbitrage
  • Working with automations
  • Essentials
    • Trade execution
    • kCoins
    • Lending
    • Borrowing
    • Fees & Protocol Income
    • Interest rates
    • Liquidations
    • Adding new tokens to the DEX
  • Tokenfactory
    • Factory tokens
    • Liquidity pool
    • Vesting
    • Offers
  • Technical details
    • Constant product
    • Prices
  • Liquidity
  • Epochs
  • Running a node
  • Transaction fees
Powered by GitBook
On this page
  1. Essentials

Liquidations

At the end of every block, the protocol calculates the maximum borrowable amount for each user who has borrowed funds. If the borrowed amount is larger than the LTV, the protocol sells collateral. Since users can borrow funds from multiple tokens and can also provide collateral in multiple denominations, the following priorities are used:

  • Borrowers get sorted by their oldest loan, i.e. the user with the loan with the lowest index gets liquidated first

  • Borrowers’ loans get liquidated by age, i.e. the loan with the lowest index gets liquidated first

  • Collateral is used by value on the DEX. I.e. the token for which there is the most liquidity on the DEX is used first.

Since interest is applied at the end of every block, the value of a loan grows by a small amount each second. The loan amount is cross-checked against the user's maximum borrowing limit at the conclusion of each block. The borrowing limit depends on the deposited collateral and every collateral currency’s LTV. Such as, when a user deposits 100 kUSD of collateral and kUSD’s LTV is 90%, then the borrowing limit is 90 kUSD and the loan value cannot be higher than that. However, a loan can be valued more than the borrowing limit due to applied interest or when the added collateral loses value. In that case, part of the collateral will be sold to partially repay the loan so that the loan value is lower than the borrowing limit.

If collateral must be sold, it is possible to sell as much collateral so that the loan value is worth exactly as much as the borrowing limit. However, since interest will be applied at the end of the next block, it would bypass the loan value’s threshold and collateral must be sold again. To prevent these micro-trades, additional collateral will be sold so that the loan value is "healthier”. The calculation is as follows:

A user deposits collateral worth 100 kUSD. Given an LTV of 90%, the borrowing limit is 90 kUSD. Due to applied interest, the loan could be valued at 90.01 kUSD. In this situation, the loan would be considered unhealthy, meaning collateral will be sold to repay part of the loan. To calculate how much collateral will be sold, the following formula will be applied: excess_borrow_amount = loan_value - (maximum_allowed_borrow_amount * discount_factor). The default discount factor is 5%. If the loan value is 90.01 kUSD and the borrowing limit is 90 kUSD, the discount factor will lower that value to 85.5, resulting in that much collateral being sold such that the new loan amount is 85.5 kUSD.

Minimum loan size

When loans are liquidated, collateral is sold to buy assets of the loan's denomination to then repay part of the loan. Per default, the sold collateral's value represents 5% of the loan's value as to bring the LTV to 95%. Of the many checks done by the DEX module before trading, one is the size of the traded amount. If the traded amount is too small, the trade is not executed, the reason being that the smaller trade amount, the bigger the impact of rounding is.

If a loan is becoming so small that trading collateral becomes an issue, the loan is dissolved, meaning the user doesn't have to repay the loan. This is an advantage to the borrower at cost of the lender. However, the sizes are so small that this cannot be gamed: The size threshold is chosen such that it is smaller than the gas price to create a loan.

PreviousInterest ratesNextAdding new tokens to the DEX

Last updated 2 months ago