Liquidation mechanism
If the value of the collateral associated with a user's Loan Module experiences a significant decline and the user fails to timely settle interest payments or bolster collateral funds, triggering a drop below the stipulated minimum pledge rate, Keepers have the authority to submit a liquidation request to the Loan Module []. Keepers simply need to adhere to the liquidation amount broadcasted by the Insurance Module, along with the corresponding Module's address. They can then execute a direct transfer to this address. Upon consensus agreement from the Indexer, the Module undergoes unlocking, transforming into a White Module. Subsequently, the Keeper initiates a withdrawal request, securing the escalated collateral. The clearing fee, configured within the Insurance contract script by the Yala Foundation, presents an opportunity for Keepers to acquire collateral at a discounted rate, capitalizing on arbitrage gains.
AMM for liquidation
Facing the high volatility of the BTC market, we explored ways to mitigate borrowers' losses when asset depreciation triggers liquidation.
The Auto Market Maker[@], widely adopted in decentralized exchanges (DEX), offers a solution by automatically setting buy and sell prices through basic algorithms, functioning like an automated trader. This innovation addresses the cost and efficiency challenges of transitioning from traditional exchanges to DEXs, facilitating seamless, unauthorized, and decentralized trading of digital assets.
Curve's novel approach employs a reverse AMM within their latest protocol, Curve Stablecoin[] , to tackle liquidation more effectively than traditional stablecoin or lending protocols like MakerDAO, Liquity, and Compound. By leveraging its AMM, Curve stablecoin enhances liquidation efficiency, significantly lowering the risk of accruing bad debts. Furthermore, the AMM aids in absorbing liquidated assets, thereby dampening market volatility induced by mass asset sales. This represents a key advancement over older stablecoin and lending models, offering a more resilient solution to liquidation challenges.
Under the BRC-20 modular protocol, there are several issues to consider when using AMM for clearing, including the black module cannot withdraw when the conditions are not met, and the flexibility of Defi under ERC cannot be realized within the module. So we design the progressive AMM clearing process applicable to Yala Finance.
As shown in the above figure, the collateral price within the module AMM changes with the market price, is the total value of the collateral when the borrower initiates the Loan Module, and the system does not do anything when the value of the collateral rises above . is the liquidation line set by Yala Foundation for collateral in advance according to the quotation of the prediction machine. When the market price of collateral is in the interval from to , the collateral price in AMM and the market price are equal, so that is the collateral price in AMM, and is the market price of collateral, which satisfies the function .
The AMM liquidation mechanism is triggered when , i.e., the market price is below the liquidation line and the borrower has not yet repaid the loan. Set
where is a constant set at Loan Module creation, i.e., the liquidation rate, that satisfies . AMM for Liquidation satisfies a constant equation similar to uniswap v3[@]:
where denotes the total amount of $YU in the Loan Module and denotes the outstanding collateral balance. As in Uniswap V3, the price (collateral price) in the AMM can be expressed like this:
Unlike Uniswap V3, both f and g in the above equation are dynamic variables and are correlated with the external price . Under the BRC-20 modularization standard, it is not appropriate to consider the condition of automatic buyback of collateral, which is cleared when is in the interval . The clearing process is initiated by the keeper who initiates the bidding of the collateral by the TRANSFER inscription, and only when the clearing is complete is the clearing of all TRANSFERS carried out, otherwise, once the collateral rises again to a healthy level, i.e., , all transfer inscriptions are returned to revert to the healthy curve after a delay of one prophet-safe time.
Next, we discuss the computation of the clearing function for the interval , and we refer to the existing results of the LLAMMA algorithm to obtain the optimal AMM price function:
At this point there is the function:
where is the total amount of collateral, the amount of collateral y = , and the amount of $YU x = 0
when the Loan Module has just been depolymerized, at which point , and
substituting into Eq. (1) and Eq. (2), we get
solves to:
and
The complete AMM constant product formula is then obtained:
This yields that can be solved for from the current x, y values:
Estimated at the beginning of the user's deploy Loan Module until the liquidation is complete: when the collateral market price decreases, the quantity obtained after all collateral in the Loan Module is traded into $YU, which we will denote as , is assumed:
The external price changes at an extremely slow rate, which means that the spread between the external price and the internal price of the Module at a given time is negligibly small.
The internal price of the Module follows the external price, and since the spread between the internal and external prices of the AMM is negligible, the keepers do not incur losses due to the spread during the trading process.
According to Uniswap V3 (6.13), we can get the liquidation completion point estimation function:
The whole AMM clearing process is controlled by the clearing script pointed within the Loan Module, when clearing starts, each keeper can send transfer inscription to the Loan Module for clearing queue, the clearing script will recursively check the bids of the keeper in order, when it satisfies when. Unlike LLAMMA, Yala Finance's liquidation process is continuous and does not include band rounds. Because under the volatile BTC market, the plunge of inscriptions may generate bad debts extremely easily, the gradual liquidation can share the risk for the keeper, and also allow the keeper to compete for arbitrage and accelerate the liquidation.
Last updated