IDelayedLiquidationGate
Git Source - Generated with forge doc
Title: IDelayedLiquidationGate
Interface of the combined ILiquidatorGate and liquidation router enforcing a grace period before liquidations.
Functions
MORPHO_MIDNIGHT
The Morpho Midnight protocol this gate is bound to.
function MORPHO_MIDNIGHT() external view returns (IMidnight);
GRACE_PERIOD
The seconds between startGracePeriod and the earliest liquidation.
function GRACE_PERIOD() external view returns (uint256);
LIQUIDATION_PERIOD
The seconds during which liquidation is permitted, starting GRACE_PERIOD after the window opened. After this period elapses without liquidation, the window expires.
function LIQUIDATION_PERIOD() external view returns (uint256);
PRIORITY_PERIOD
The seconds at the start of the liquidation window during which only the priorityLiquidator recorded at startGracePeriod time may liquidate. Once elapsed, or if it is address(0), any address may liquidate.
function PRIORITY_PERIOD() external view returns (uint256);
gracePeriodInfo
Returns the last recorded grace period entry of (borrower, marketId). Entries are never cleared, so expired or consumed windows return stale data.
function gracePeriodInfo(address borrower, bytes32 marketId)
external
view
returns (uint56 timestamp, address priorityLiquidator);
startGracePeriod
Opens the grace window on an unhealthy position.
Reverts if a window is already open.
Reverts if the position is still healthy at call time.
Reverts if the position's liquidation is locked on Midnight.
function startGracePeriod(bytes32 marketId, address borrower, address _priorityLiquidator) external;
Parameters
| Name | Type | Description |
|---|---|---|
marketId | bytes32 | The market in distress. |
borrower | address | The borrower being liquidated. |
_priorityLiquidator | address | The address with exclusive liquidation rights during the priority sub-window. |
liquidate
Liquidates a position whose grace window has elapsed.
Pre-maturity, reverts if no grace window has been opened, before GRACE_PERIOD elapses, after the window expires, or during the priority sub-window when called by a non-priority address.
Past market.maturity, the window checks are skipped and liquidation via this gate is permissionless.
function liquidate(
Market calldata market,
uint256 collateralIndex,
uint256 seizedAssets,
uint256 repaidUnits,
address borrower,
bool postMaturityMode,
address receiver,
address callback,
bytes calldata data
) external returns (uint256, uint256);
Parameters
| Name | Type | Description |
|---|---|---|
market | Market | |
collateralIndex | uint256 | |
seizedAssets | uint256 | |
repaidUnits | uint256 | |
borrower | address | |
postMaturityMode | bool | Selects the Midnight liquidation mode: true = post-maturity mode (requires block.timestamp > market.maturity; LIF ramps from 1 to maxLif over TIME_TO_MAX_LIF; RCF disabled), false = normal mode (requires originalDebt > maxDebt; LIF = maxLif; RCF applies). See IMidnight.liquidate. |
receiver | address | The address receiving the seized collateral, forwarded to Midnight. |
callback | address | Optional flash-liquidation callback. Must be zero or the caller; when nonzero, must implement ILiquidateCallback.onLiquidate. |
data | bytes | Arbitrary data forwarded to the callback's onLiquidate. |
Events
GracePeriodStarted
event GracePeriodStarted(
address indexed borrower, bytes32 indexed marketId, uint256 timestamp, address priorityLiquidator
);
Errors
GracePeriodAlreadyActive
error GracePeriodAlreadyActive();
PositionIsHealthy
error PositionIsHealthy();
PositionLocked
error PositionLocked();
NotMorpho
error NotMorpho();
LiquidationNotAllowed
error LiquidationNotAllowed();
InvalidCallback
error InvalidCallback();
Structs
GracePeriodInfo
Packed into a single storage slot: uint56 (7 bytes) + address (20 bytes) = 27 bytes.
struct GracePeriodInfo {
uint56 timestamp;
address priorityLiquidator;
}