{"id":26054846,"url":"https://github.com/morpho-org/pre-liquidation","last_synced_at":"2026-04-23T09:35:05.089Z","repository":{"id":258979101,"uuid":"849462426","full_name":"morpho-org/pre-liquidation","owner":"morpho-org","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-15T11:44:31.000Z","size":5064,"stargazers_count":14,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-15T15:37:11.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morpho-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-29T16:31:15.000Z","updated_at":"2025-12-01T23:35:53.000Z","dependencies_parsed_at":"2024-10-29T04:19:06.095Z","dependency_job_id":null,"html_url":"https://github.com/morpho-org/pre-liquidation","commit_stats":null,"previous_names":["morpho-org/pre-liquidation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/morpho-org/pre-liquidation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpre-liquidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpre-liquidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpre-liquidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpre-liquidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/pre-liquidation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpre-liquidation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32174759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T02:19:40.750Z","status":"ssl_error","status_checked_at":"2026-04-23T02:17:55.737Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-08T10:00:22.829Z","updated_at":"2026-04-23T09:35:05.074Z","avatar_url":"https://github.com/morpho-org.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PreLiquidation\n\n## Overview\n\nThis repository puts together different contracts to carry out liquidations on Morpho with specific parameters chosen by the borrower.\nWe call these user-defined Morpho Blue transactions pre-liquidations.\nBorrowers can set custom pre-liquidation parameters, allowing them to specify pre-liquidation incentive factors and pre-liquidation close factors.\nPre-liquidation incentive factors determine incentives given to liquidators and pre-liquidation close factors limit the proportion of the position that can be closed during a liquidation.\n\nThe [`PreLiquidation`](./src/PreLiquidation.sol) contract serves as the endpoint for pre-liquidations using parameters chosen by borrowers.\nNote that pre-liquidation must be authorized on Morpho.\nLiquidators may perform pre-liquidations on a position using the `preLiquidate` entry point on a deployed `PreLiquidation` contract.\nThe [`PreLiquidationFactory`](./src/PreLiquidationFactory.sol) factory contract simplifies the deployment and indexing of pre-liquidation contracts.\n\nThe set of pre-liquidation parameters is composed of\n\n- a Morpho market (`id`);\n- a pre-liquidation loan-to-value (`preLltv`);\n- two pre-liquidation close factor parameters (`preLCF1` and `preLCF2`);\n- two pre-liquidation incentive factor parameters (`preLIF1` and `preLIF2`);\n- a pre-liquidation oracle (`preLiquidationOracle`).\n\n### Pre-liquidation close factor and incentive factor\n\nThe pre-liquidation close factor and the pre-liquidation incentive factor evolve linearly with the user's LTV:\n\n- the pre-liquidation close factor is `preLCF1` when the position LTV is equal to `preLltv` and `preLCF2` when the LTV is equal to `LLTV`;\n- the pre-liquidation incentive factor is `preLIF1` when the position LTV equals `preLltv` and `preLIF2` when the LTV is equal to `LLTV`.\n\nThese functions are illustrated in the following figure:\n\n\u003cimg width=\"1061\" alt=\"pre-liquidation-cf-and-lif\" src=\"https://github.com/user-attachments/assets/7d65a88e-8187-4b90-848e-9aa5ee66b971\"\u003e\n\nThe two main use-cases are:\n\n1. Using normal fixed parameters when `preLIF1 = preLIF2` and `preLCF1 = preLCF2`.\n2. Using health dependent liquidation when either `preLIF1 \u003c preLIF2` or `preLCF1 \u003c preLCF2`, similar to a Quasi Dutch Auction (as in [Euler liquidations](https://docs-v1.euler.finance/getting-started/white-paper#liquidations)).\n\n### Pre-liquidation parameters restrictions\n\nThe PreLiquidation smart-contract enforces the properties:\n\n- `preLltv \u003c LLTV`;\n- `preLCF1 \u003c= preLCF2`;\n- `preLFC1 \u003c= 1`;\n- `1 \u003c= preLIF1 \u003c= preLIF2 \u003c= 1 / LLTV`.\n\nNote: A pre-liquidation close factor higher than 100% means that the whole position is pre-liquidatable, so using `preLCF2 \u003e 1` allows to make the position entirely pre-liquidatable at a LTV between preLltv and LLTV.\n\nThe property `preLIF2 \u003c= 1 / LLTV` and the fact that pre-liquidations are only allowed for `LTV \u003c= LLTV` ensure that pre-liquidations can't worsen the health of the position.\n\n### `onPreLiquidate` callback\n\nBy calling `preLiquidate` with a smart contract that implements the `IPreLiquidationCallback` interface, the liquidator can be called back.\nMore precisely, the `onPreLiquidate` function of the liquidator's smart contract will be called after the collateral withdrawal and before the debt repayment.\nThis mechanism eliminates the need for a flashloan.\n\n### PreLiquidation Oracle\n\nThe `PreLiquidationParams` struct includes a `preLiquidationOracle` attribute, allowing pre-liquidation using any compatible oracle.\nThis oracle should implement [Morpho's `IOracle` interface](https://github.com/morpho-org/morpho-blue/blob/main/src/interfaces/IOracle.sol) and adhere to the behavior specified in the documentation.\nIt's possible to use the corresponding market oracle or any other oracle including OEV solutions.\n\n### PreLiquidationAddressLib\n\nPreLiquidation contract addresses are generated using the CREATE2 opcode, allowing for predictable address computation depending on pre-liquidation parameters.\nThe [`PreLiquidationAddressLib`](./src/libraries/periphery/PreLiquidationAddressLib.sol) library provides a `computePreLiquidationAddress` function, simplifying the computation of a PreLiquidation contract's address.\n\n### Potential preLCF manipulation\n\nA pre-liquidation cannot repay a proportion of the position's debt greater than `preLCF`.\nHowever, it's possible to pre-liquidate a proportion of the position while keeping it pre-liquidatable before performing another pre-liquidation.\nThis manipulation can lead to repaying a proportion of the position's debt higher than `preLCF`.\nIt has been studied in the part 5.2 of [An Empirical Study of DeFi Liquidations:Incentives, Risks, and Instabilities](https://arxiv.org/pdf/2106.06389), in the case of a constant liquidation close factor.\nImplementing a `preLCF` linear in the health factor can help mitigating this manipulation when choosing the right slope.\n\n## Developers\n\n\u003e [!NOTE]\n\u003e `PreLiquidationFactory` has been deployed on Ethereum and Base with the [metadata hash](https://docs.soliditylang.org/en/latest/metadata.html) included, which appear at two places in the bytecode as it is a factory.\n\n### Package installation\n\nInstall [Foundry](https://book.getfoundry.sh/getting-started/installation).\n\n### Run tests\n\nRun `forge test`.\n\n## Solidity version\n\nAs a consequence of using Solidity 0.8.27, the bytecode of the contracts could contain new opcodes (e.g., `PUSH0`, `MCOPY`, `TSTORE`, `TLOAD`) so one should make sure that the contract bytecode can be handled by the target chain for deployment.\n\n## Audits\n\nAll audits are stored in the [`audits`](./audits) folder.\n\n## License\n\nFiles in this repository are publicly available under license `GPL-2.0-or-later`, see [`LICENSE`](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fpre-liquidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fpre-liquidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fpre-liquidation/lists"}