Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ora-io/marine
Trustless Liquidation Keeper with zkGraph for Compound Protocol
https://github.com/ora-io/marine
compound-protocol defi zkgraph zkoracle
Last synced: 3 months ago
JSON representation
Trustless Liquidation Keeper with zkGraph for Compound Protocol
- Host: GitHub
- URL: https://github.com/ora-io/marine
- Owner: ora-io
- Created: 2023-10-09T05:56:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-09T02:26:45.000Z (about 1 year ago)
- Last Synced: 2024-06-17T11:34:13.988Z (5 months ago)
- Topics: compound-protocol, defi, zkgraph, zkoracle
- Language: JavaScript
- Homepage: https://www.hyperoracle.io/
- Size: 406 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-ora - Marine
README
# 🐳 [Marine](https://mirror.xyz/hyperoracleblog.eth/iXLTbbggNTtLWqPB695IvJQo2DtgooEbvYVVuFVY6y8): Compound Protocol Liquidation Keeper
A zkGraph for determining whether any Compound account can be liquidated and then performing liquidation as keeper.
Built using [HyperOracle](https://www.hyperoracle.io), a programmable zkOracle protocol.
# Getting Start
Test Marine locally by these steps.
### 1. Set up environment
```sh
npm install
vim config.js # Fill in the private key and endpoint in the configuration file.
```### 2. Access the status of monitored Compound account
```sh
npm run marine -- 0x77C6d4c010EaeF7C0dC0080F78ded522AB58A926
```### 3. Obtain the price of underlying assets
```sh
npm run prices
```### 4. Compile && Run with specified block height
```sh
npm run compile-local && npm run exec-local -- 18370576
```Then 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.
# Technical Details
### Project Layout
- 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.### Core logic
1. Fetch events from Compound Protocol. Instantiate the events in receipts into corresponding EventClass.
2. 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 respectively `src/static/price.ts` and `src/static/marine.ts`. The core file that tracks the state, `src/static/tokens`, will reference them.
3. Calculate the user's `totalCollateralValue` and `totalPrincipalValue` by `assetAggregator`. The computation of `totalCollateralValue` needs to take into account the `cToken.collateralFactor` and its corresponding exchangeRate.
4. Compare `totalValue` and `totalPrincipal`, if `totalPrincipal` is larger, then the user can be liquidated.