computeLiqOpp() :
This function computes the liquidation opportunity for a given violator account. It first checks that the violator is entered in the markets for both the underlying and collateral assets, and then calculates the health score of the account. It then calculates the discount rate for the liquidation, based on the liquidator's account balance, and the conversion rate between the underlying and collateral assets. It then calculates the maximum amount of repay and yield that can be generated from the liquidation, taking into account the current owed amount and the collateral balance of the violator. Finally, it adjusts the repay amount to account for the underlying reserves fee. (autogenerated documentation)
computeDiscountBooster(address) :
This function computes a discount booster for a given liquidator and violator liability value. It does this by first calculating the updated average liquidity of the liquidator with a delegate, then dividing that value by the violator liability value. If the result is greater than 1e18, it is set to 1e18. The result is then multiplied by the discount booster slope minus 1e18, and 1e18 is added to the result. The final result is the discount booster. (autogenerated documentation)
checkLiquidation(address,address,address,address) :
This function checks for a liquidation opportunity for a given set of addresses. It takes four parameters: the liquidator address, the violator address, the underlying asset address, and the collateral asset address. It then stores these addresses in a memory structure called LiquidationLocals and calls the computeLiqOpp() function to compute the liquidation opportunity. Finally, it returns the LiquidationOpportunity memory structure containing the details of the liquidation opportunity. (autogenerated documentation)
liquidate(address,address,address) :
This function is used to liquidate a user's position in a decentralized finance (DeFi) protocol. It takes in the address of the violator (the user whose position is being liquidated), the address of the underlying asset, the address of the collateral asset, the amount to be repaid, and the minimum yield. The function first checks that the violator has not deferred their liquidity, and then emits a RequestLiquidate event. It then updates the average liquidity of both the liquidator and the violator. It then computes the liquidation opportunity by setting up the LiquidationLocals memory structure. Finally, it executes the liquidation by calling the executeLiquidation function with the LiquidationLocals memory structure (autogenerated documentation)
executeLiquidation() :
This function is used to execute a liquidation. It takes two parameters, desiredRepay and minYield, and a LiquidationLocals struct containing information about the liquidation opportunity. First, it calculates the amount of repay that will be transferred to the liquidator, taking into account any fees associated with the transaction. Then, it calculates the yield that the liquidator will receive from the liquidation, ensuring that it is at least equal to the minYield parameter. Finally, it transfers the repay and yield to the liquidator, and emits a LiquidationLog event. (autogenerated documentation)
emitLiquidationLog() :
This function emits an event called Liquidation which contains information about a liquidation event. It takes in a LiquidationLocals memory struct which contains information about the liquidator, violator, underlying asset, collateral, repayment amount, yield, health score, base discount, and discount. It then emits the Liquidation event with all of this information. (autogenerated documentation)