Liquidator contract
repository url: gfx.cafe: https://gfx.cafe/ip/liquidator
Deployment: https://etherscan.io/address/0x0f131c38a552142d5753363090f6f7c4e01ab0e4
setup
to setup the repo first run
npm i
then cp SAMPLE.env .env
and fill up .env with some values
compile
to compile the contracts, simply run
npx hardhat compile
test
npx hardhat test
explainer
This contract uses flash loans to procure enough funds to liquidate positions of virtually any size, without the need for the caller to possess any funds other than the ether to cover the gas cost.
In short, a liquidation on Interest Protocol is essentially a liquidator buying a borrower's collateral at a discounted rate using USDi.
This liquidator contract uses USDC or USDi liquidity to do this and then sells the collateral on UniswapV3 at current market rates, thus yielding a profit. After repaying the flash loan, the remaining profit is sent to the caller of the function.
This will allow anyone to liquidate any position that is underwater on Interest Protocol, profiting the community and keeping the protocol solvent.
Anyone can call either of the two liquidate functions and profit from the liquidation. There is an optional check to ensure the gas cost to perform the liquidation does not exceed the revenue gained by the liquidator.