🐳 Marine: Compound Protocol Liquidation Keeper
A zkGraph for determining whether any Compound account can be liquidated and then performing liquidation as keeper.
Built using HyperOracle, a programmable zkOracle protocol.
Test Marine locally by these steps.
npm install
vim config.js # Fill in the private key and endpoint in the configuration file.npm run marine -- 0x77C6d4c010EaeF7C0dC0080F78ded522AB58A926npm run pricesnpm run compile-local && npm run exec-local -- 18370576Then zkGraph returns a boolean value right after 0x53ad370d in the result to indicate whether the user can be liquidated. In production, the return value will be the payload / calldata for triggering liquidation onchain.
- src - Core logic of Marine.
- builds - Compiled WASM Binary file and Compound user state file
- APIs - Libraries including zkgraph-api and other scripts for obtaining user accounts and underlying status.
- Fetch events from Compound Protocol. Instantiate the events in receipts into corresponding EventClass.
- If there is a Sync event, update the underlying asset prices specified in the configs. If there is
Mint/Redeem/Borrow/RepayBorrow, update the defined Compound user state. The files for underlying prices and Compound user status are respectivelysrc/static/price.tsandsrc/static/marine.ts. The core file that tracks the state,src/static/tokens, will reference them. - Calculate the user's
totalCollateralValueandtotalPrincipalValuebyassetAggregator. The computation oftotalCollateralValueneeds to take into account thecToken.collateralFactorand its corresponding exchangeRate. - Compare
totalValueandtotalPrincipal, iftotalPrincipalis larger, then the user can be liquidated.