Skip to content

6ixtyy/liquidation_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compound v2 Liquidation Bot

A sophisticated Solidity-based bot that demonstrates the historical price manipulation vulnerability in Compound v2 during DeFi Summer 2020.

Overview

This project replicates the historical exploit where a liquidator gained an edge by manipulating the Open Price Feed in Compound v2. The bot demonstrates how stale but valid signed prices could be used to trigger liquidations before other market participants could react.

Key Features

  • Simulates price manipulation using stale-but-valid signed price data
  • Executes liquidateBorrow() on undercollateralized accounts
  • Built with Foundry for efficient testing and deployment
  • Uses mainnet forking for realistic testing conditions
  • Demonstrates the exact attack vector used on August 20, 2020

🚀 Getting Started

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/6ixty80/liquidation-bot.git
cd liquidation-bot
  1. Install dependencies:
forge install
  1. Build the project:
forge build

Testing

Run the test suite:

forge test

For verbose output:

forge test -vv

Configuration

The bot can be configured through environment variables:

  • RPC_URL: Your Ethereum node RPC URL
  • PRIVATE_KEY: Your wallet's private key
  • GAS_PRICE: Maximum gas price in wei
  • GAS_LIMIT: Gas limit for transactions

Disclaimer

This project is for educational purposes only. It demonstrates a historical vulnerability that has been patched in newer versions of Compound. Do not use this code for malicious purposes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details on our code of conduct and the process for submitting pull requests.

About

liquidation_bot

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published