{"id":26121959,"url":"https://github.com/lbkolev/aave-liquidation","last_synced_at":"2026-07-01T00:32:36.690Z","repository":{"id":281280797,"uuid":"944800723","full_name":"lbkolev/aave-liquidation","owner":"lbkolev","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-10T14:45:56.000Z","size":216,"stargazers_count":20,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T18:49:06.865Z","etag":null,"topics":["aave","defi","ethereum","evm","liquidation"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lbkolev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-03-08T01:49:39.000Z","updated_at":"2025-08-10T05:29:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"da54c612-2117-4662-ac84-d873878b3251","html_url":"https://github.com/lbkolev/aave-liquidation","commit_stats":null,"previous_names":["lbkolev/aave-liquidation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lbkolev/aave-liquidation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbkolev%2Faave-liquidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbkolev%2Faave-liquidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbkolev%2Faave-liquidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbkolev%2Faave-liquidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lbkolev","download_url":"https://codeload.github.com/lbkolev/aave-liquidation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbkolev%2Faave-liquidation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34988712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["aave","defi","ethereum","evm","liquidation"],"created_at":"2025-03-10T14:37:39.890Z","updated_at":"2026-07-01T00:32:36.672Z","avatar_url":"https://github.com/lbkolev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Standalone AaveV3 liquidation bot, unlikely to be profitable nowadays.\n\n## Components:\n\n- `contracts/` - contains example contract used to execute liquidations\n- `src/` - contains the offchain logic responsible for tracking and managing liquidation opportunities\n- `migrations/` - holds the database migrations\n\nThe offchain service is built with actix's [actor model](https://en.wikipedia.org/wiki/Actor_model) in mind.\n\nThe setup is abstracted enough to work on any and all Aave forks, on all EVM-compatible chains, so long as you know the deployment address of the protocol's:\n\n- `Pool`\n- `PoolAddressesProvider`\n- `UiPoolDataProviderV3`\n\nSimply create a new migration file in `migrations/`, copy [20240101010102_insert_val](./migrations/20240101010102_insert_val.sql) and adjust the values accordingly.\n\n## Idiosyncrasies\n\n- all reserves's real time value is tracked by listening for `AnswerUpdated`, emitted by Chainlink's price aggregators.\n- users's open positions \u0026 exposure is kept both in-memory and in postgres for later usage\n- the smart contract executing the liquidation relies on flashloan to execute the liquidation\n\n# Example usage\n\n- deploy the contract (perhaps locally through anvil fork `anvil --fork-url https://eth.merkle.io`)\n\n- start postgres\n\n```bash\ndocker-compose up -d postgres\n```\n\nrun the offchain service\n\n```bash\n# the used pubkey \u0026 privkey are the default ones provided by anvil.\ncargo r -- \\\n    --network ethereum --protocol aave_v3 \\\n    --ws-url=wss://eth.merkle.io \\\n    --account-pubkey=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 \\\n    --account-privkey=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \\\n    --bot-addr=0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5\n```\n\n# Flow\n\nThe flow of execution goes like\n\n```mermaid\nsequenceDiagram\n\nparticipant DB as DBActor\nparticipant Fanatic as FanaticActor\nparticipant Follower as FollowerActor\nparticipant Executor as ExecutorActor\n\nFanatic -\u003e\u003e DB: GetProtocolDetailsId\nFanatic -\u003e\u003e DB: GetProtocolContracts\nFanatic -\u003e\u003e DB: GetReservesUsers\n\nFanatic -\u003e Fanatic: init_reserves()\n\nFanatic -\u003e\u003e Follower: SendFanaticAddr\nFanatic -\u003e\u003e Follower: StartListeningForOraclePrices\nFanatic -\u003e\u003e Follower: StartListeningForEvents\n\nrect rgb(30, 30, 30)\n    Follower -\u003e\u003e Follower: listen_oracle_prices()\n    Follower -\u003e\u003e DB: UpdateOraclePrice\n    Follower -\u003e\u003e Fanatic: UpdateReservePrice\n    Fanatic -\u003e\u003e Fanatic: verify health factors\n    Fanatic -\u003e\u003e Fanatic: update in memory state\n    Fanatic -\u003e\u003e Executor: liquidation request\n    Executor --\u003e Executor: verify opportunity is profitable\n    Executor --\u003e Executor: execute liquidation\nend\n\nrect rgb(30, 30, 30)\n    Follower -\u003e\u003e Follower: listen_events()\n    rect rgb(40, 40, 40)\n        Follower -\u003e\u003e Fanatic: DoSmthWithLiquidationCall\n        Fanatic -\u003e\u003e DB: InsertLiquidation\n    end\n\n    rect rgb(50, 50, 50)\n        Follower -\u003e\u003e Fanatic: UpdateReserveUser\n        Fanatic -\u003e\u003e Fanatic: verify health factor\n        Fanatic -\u003e\u003e Fanatic: update in memory state\n        Fanatic -\u003e\u003e Executor: liquidation request\n        Executor --\u003e Executor: verify opportunity is profitable\n        Executor --\u003e Executor: execute tx\n    end\n\n    rect rgb(60, 60, 60)\n        Follower -\u003e\u003e DB: UpsertReserveStats\n    end\nend\n```\n\n# Database schema\n\n```mermaid\nerDiagram\n    NETWORKS ||--o{ PROTOCOLS_DETAILS : has\n    PROTOCOLS ||--o{ PROTOCOLS_DETAILS : has\n    PROTOCOLS ||--o{ PROTOCOLS : forks\n    PROTOCOLS_DETAILS ||--o{ PROTOCOLS_CONTRACTS : contains\n    NETWORKS ||--o{ ERC20_DETAILS : has\n    ERC20 ||--o{ ERC20_DETAILS : has\n    PROTOCOLS_DETAILS ||--o{ AAV3_USERS : has\n    PROTOCOLS_DETAILS ||--o{ AAV3_RESERVES : has\n    AAV3_USERS ||--o{ AAV3_USERS_STATS : tracks\n    ERC20_DETAILS ||--o{ AAV3_RESERVES : provides\n    AAV3_RESERVES ||--o{ AAV3_RESERVES_STATS : tracks\n    AAV3_USERS ||--o{ AAV3_POSITIONS : has\n    AAV3_RESERVES ||--o{ AAV3_POSITIONS : uses\n    PROTOCOLS_DETAILS ||--o{ AAV3_LIQUIDATIONS : records\n    AAV3_RESERVES ||--o{ AAV3_LIQUIDATIONS : involves\n\n    NETWORKS {\n        VARCHAR(50) id PK\n        INTEGER chain_id\n        TIMESTAMP created_at\n    }\n\n    PROTOCOLS {\n        VARCHAR(50) id PK\n        VARCHAR(100) name\n        VARCHAR(50) kind\n        VARCHAR(50) fork FK\n        TIMESTAMP created_at\n    }\n\n    PROTOCOLS_DETAILS {\n        SERIAL id PK\n        VARCHAR(50) protocol_id FK\n        VARCHAR(50) network_id FK\n        BIGINT deployed_block\n        TIMESTAMP deployed_at\n        TIMESTAMP created_at\n    }\n\n    PROTOCOLS_CONTRACTS {\n        SERIAL id PK\n        INTEGER protocol_details_id FK\n        VARCHAR(100) name\n        CHAR(42) address\n        TIMESTAMP created_at\n    }\n\n    ERC20 {\n        SERIAL id PK\n        VARCHAR(10) symbol\n        VARCHAR(100) name\n        TIMESTAMP created_at\n    }\n\n    ERC20_DETAILS {\n        SERIAL id PK\n        CHAR(42) address\n        INTEGER decimals\n        INTEGER erc20_id FK\n        CHAR(50) network_id FK\n        TIMESTAMP created_at\n    }\n\n    AAV3_USERS {\n        CHAR(42) address PK\n        INTEGER protocol_details_id FK\n        TIMESTAMP created_at\n    }\n\n    AAV3_USERS_STATS {\n        CHAR(42) user_address PK,FK\n        DOUBLE_PRECISION health_factor\n        TIMESTAMP updated_at\n    }\n\n    AAV3_RESERVES {\n        CHAR(42) reserve PK,FK\n        INTEGER protocol_details_id FK\n        DOUBLE_PRECISION liquidation_threshold\n        DOUBLE_PRECISION liquidation_bonus\n        BOOLEAN flashloan_enabled\n        CHAR(42) oracle_addr\n        CHAR(42) aggregator_addr\n        TIMESTAMP created_at\n    }\n\n    AAV3_RESERVES_STATS {\n        CHAR(42) reserve PK,FK\n        DOUBLE_PRECISION liquidity_index\n        DOUBLE_PRECISION liquidity_rate\n        DOUBLE_PRECISION variable_borrow_rate\n        DOUBLE_PRECISION variable_borrow_index\n        DOUBLE_PRECISION price_usd\n        TIMESTAMP updated_at\n        TIMESTAMP created_at\n    }\n\n    AAV3_POSITIONS {\n        SERIAL id PK\n        CHAR(42) user_address FK\n        CHAR(42) reserve FK\n        DOUBLE_PRECISION supply_amount\n        DOUBLE_PRECISION borrow_amount\n        TIMESTAMP updated_at\n        TIMESTAMP created_at\n    }\n\n    AAV3_LIQUIDATIONS {\n        SERIAL id PK\n        INTEGER protocol_details_id FK\n        CHAR(42) user_address\n        CHAR(42) collateral_asset FK\n        CHAR(42) debt_asset FK\n        TIMESTAMP timestamp\n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbkolev%2Faave-liquidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flbkolev%2Faave-liquidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbkolev%2Faave-liquidation/lists"}