liquidate
call to the VaultManager
contract where the vault is, paying back a portion of the debt owed by the vault and receiving discounted collateral in return.VaultManager
can be liquidated, then both of them can liquidated in one transaction with just one stablecoin transfer from the liquidator and collateral transfer to it.liquidate
functions in the VaultManager
contract.liquidate()
call, you must:uint256
defining the ID of vaults) which health factor are below 1.VaultManager
(that is the contract corresponding to a collateral type-stablecoin pair in Angle Borrowing Module) in which liquidation should take place: this is the contract in which you will have to call the liquidate
functionSwapper
contract or directly bring the stablecoins to repay. In the first case, you may want to look at our guide here to see how to use Swapper
contract in your Angle execution flow.checkLiquidation
defined in each VaultManager
contract. When called on a given vaultID
that is liquidable, this function returns several elements which can be used in a subsequent liquidation call:maxStablecoinAmountToRepay
: Maximum stablecoin amount that can be repaid by liquidators upon liquidating the vaultmaxCollateralAmountToGive
: This is the amount of collateral you would receive if you were to repay maxStablecoinAmountToRepay
thresholdRepayAmount
: For some vaults, if liquidators were to liquidate a certain portion of their debt, then these vaults may end up with a "dusty" amount of debt of collateral in it. The protocol prevents liquidators from putting vaults in situations like that. As such, a non-null thresholdRepayAmount
means that you can repay an amount of the debt either smaller to this thresholdRepayAmount
or exactly equal to the maxStablecoinAmountToRepay
discount
: Discount you will get on the oracle value price of the collateralcurrentDebt
: Total amount of debt in the vaultcheckLiquidation
in the same transaction as the liquidate
call. If you're not sure about the maxStablecoinAmountToRepay
, the protocol will round the amount
value you pass in the liquidation function to the maxStablecoinAmountToRepay
if it is superior to the thresholdRepayAmount
in case it is not null or to the maxStablecoinAmountToRepay
.VaultManager
contract checkLiquidation
for all existing vaults (you may simply iterate over the vaultIDCount
variable to get all these vaults). Since this just requires repeatedly calling a view function, it does not incur any cost.from
address from which stablecoins should be taken. This address should have approved for the stablecoin the address used to trigger the liquidation. You can also specify a to
address to which collateral will be sent.who
contract as well as some data
to swap the obtained collateral for stablecoins (or just a portion of it to minimize slippage) efficiently.stablecoinAmountToReceive
: This is the amount of stablecoins you have given for the liquidationcollateralAmountToGive
: Current amount of collateral you've gotten from the contractbadDebtFromLiquidation
: Bad debt accrued across the liquidation processoracleValue
: Oracle value at which the liquidation took placenewInterestAccumulator
: Value of the interestAccumulator
at the time of the call (this is a value used to track vaults outstanding debt)getVaultDebt
.VaultManager
contract.f(veANGLE delegated balance)
constant for all liquidators. To see if this is not the case, you should check the xLiquidationBoost
and yLiquidationBoost
fields of the corresponding VaultManager
contract.