1. Merge _liquidate() into liquidate_extended()
2. Simplify the code knowing that the argument `user` is always equal to `msg.sender`
3. Simplify the code knowing that the argument `use_eth` is always equal to `true`
4. Simplify the code knowing that the argument `frac` is always equal to `10**18`
5. Simplify the code knowing that the argument `min_x` is always equal to `0`
6. Strip types
7. Replace `xy = ...` to `stablecoin_amount, collateral_amount = ...`
8. Simplify the code by adding a `require(debt > stablecoin_amount)`
9. Simplify the code knowing that `callbacker` is always `empty(address)`
10. Replace unsafe_ by respective math ops
def liquidate_extended():
"""
Perform a bad self-liquidation if health is not good
"""
debt, rate_mul = self._debt(msg.sender)
stablecoin_amount, collateral_amount = AMM.withdraw(msg.sender, self._get_f_remove(10**18, 0))
require(debt > stablecoin_amount)
STABLECOIN.transferFrom(AMM.address, self, stablecoin_amount)
to_repay = debt - stablecoin_amount
self._withdraw_collateral(msg.sender, collateral_amount)
STABLECOIN.transferFrom(msg.sender, self, to_repay)
self.redeemed += debt
self.loan[msg.sender] = Loan({initial_debt: 0, rate_mul: rate_mul})
self._remove_from_list(msg.sender)
d = self._total_debt.initial_debt * rate_mul / self._total_debt.rate_mul
self._total_debt.initial_debt = max(d, debt) - debt
self._total_debt.rate_mul = rate_mul
Imagine you are a security researcher and you are auditing [DESCRIBE THE PROJECT]. [DESCRIBE TECHNICAL DETAILS]. To find vulnerabilities in the project, you must read these functions and ask three of the most important edge-case questions about them. This will help you identify bugs or vulnerabilities. What would those three questions be? Ask very specific questions and provide suspicious arguments and code path you want to check.