Liquidation Function
Liquidate
This function allows you to liquidate an obligation account that has unhealthy condition. Anyone can perform the liquidation if the obligation is in unhealthy condition. Additionally, you need to update the oracle price before proceeding with the liquidation.
Modules:
Parameters
Name
Type
Description
version
Version
The version control object, contract version must match with this
obligation
Obligation
The obligation id object
market
Market
The Scallop market object, it contains base assets, and related protocol configs
available_repay_coin
Coin
Coin object that used to repay the debt of obligation.
coin_decimals_registry
CoinDecimalsRegistry
The package that has decimal coin of base assets.
x_oracle
XOracle
The x-oracle object which provides the price of assets
clock
Clock
The SUI system clock object
Return Values
Coin
Coin
The remaining base asset
Coin
Coin
The liquidated collateral
Events
LiquidateEventV2 is emited when the supply tx success
Errors
770: Means current obligation is locked and need to unstake first from borrow incentive
1537: Unable liquidated because liquid amount is not lower than or equal 0
Example:
Check here the example how to do update price x_oracle
We recommend you to call this function using our Scallop SDK, so before calling any function related to liquidation, you need to call update price in the beginning of the PTB (Programmable Transaction Block).
Here what your PTB should looks like:
Last updated