# Liquidation

In Aptin liquidation contracts, all users' assets are denominated in USD.
User "Borrow Balance" and "Supply Balance" are calculated using our 2 oracles, Pyth (main) and Switchboard (backup). Using these oracles, we can calculate user current LTV and Debt ratio. Liquidation in the Aptin protocol having the following risk management parameters:
• LTV (loan to value)
• Liquidation Threshold
• Debt ratio
• Liquidation Penalty

The Loan to Value (”LTV”) ratio defines the maximum amount of assets that can be borrowed with a specific csupply, borrowers will be able to borrow 800$worth of the corresponding currency). Once a borrow occurs, the LTV evolves with market conditions. For each wallet, the Liquidation Threshold is calculate as the weighted average of the Liquidation Thresholds of the supply assets and their value: $Liquidation \: Threshold= \frac{ \sum{Supply_i \: in \: USD \: \times \: Liquidation \: Threshold_i}}{Total \: Supply \: in \: USD \:}$ ### Liquidation Threshold The liquidation threshold is the percentage at which a position is defined as undercollateralised. For example, a Liquidation threshold of 85% means that if the value rises above 80% of the collateral, the position is undercollateralised and could be liquidated. The delta between the LTV and the Liquidation Threshold is a safety mechanism in place for borrowers. For each wallet, the Liquidation Threshold is calculate as the weighted average of the Liquidation Thresholds of the collateral assets and their value: $Liquidation \: Threshold= \frac{ \sum{Supply_i \: in \: USD \: \times \: Liquidation \: Threshold_i}}{Total \: Supply \: in \: USD \:}$ ### Debt ratio For each wallet, these risks parameters enable the calculation of the debt ratio: $H_f = \frac{ \sum{Supply_i \: in \: USD \: \times \: Liquidation \: Threshold_i}}{Total \: Borrows \: in \: USD}$ When $H_f ≥ 0.85$ the position may be liquidated. ### Liquidation Penalty The liquidation penalty is 5% and the penalty is used as the Aptin DAO Vault Reserve and Agreement Reserve. ## Liquidator The liquidator of Aptin is the Aptin Liquidation Contract. When the liquidation of a user's account is triggered, the liquidation contract will calculate the user's Total debt (including the outstanding interest). The liquidation contract uses the maximum value of the user's Total Supply for liquidation. After the liquidation is completed, the liquidation contract returns the user's remaining assets. (Due to price fluctuations and transaction slippage during the liquidation process, which can lead to deviations in the liquidated funds, the maximum value is used for liquidation in order to protect the security of the Aptin agreement, and the liquidation details are displayed in the user's liquidation record) Aptin liquidation using DEX as the counterparty, the current Aptin integrated DEX for Hippo. ### Liquidation Example Bob supplies 1BTC to Aptin and borrows 10ETH. at the time of borrowing, the price of BTC is$20,000 and the price of ETH is $1500. After converting to USD, the Totol supply of BoB account is$20,000 and Total debt is $15,000. Assuming the BTC price remains unchanged, when the ETH price rises by 1.13%, the Debt ratio of BoB account reaches 85%, triggering the liquidation contract. The liquidation contract liquidates BoB's account at a price of$1700 per unit of ETH.
The liquidation contract submits Bob's 1BTC to DEX for liquidation. During the liquidation process, Aptin charges a 5% liquidation penalty, which means BoB's Total debt is actually $17,850. Assuming the BTC price is$20,000 at the time of liquidation, the liquidation contract sells 0.8925 BTC in BoB's account at DEX and receives $17,850. Of which$17,000 to pay BoB debt, \$850 as a liquidation penalty, the remaining 0.1075BTC returned to the BOB account to complete the liquidation.