Skip to content

jorgejch/dex-arbitrage

Repository files navigation

Another Flash-loan Arbitrage Bot (AFLAB)

Quality Gate Status codecov

What?

Another Flash-loan arbitrage bot that:

  • is low cost, works on Polygon;
  • uses AAVE for flash-loans;
  • performs swaps on Uniswap v3 (the DEX);
  • makes use of established patterns when they exist;
  • prefers open-source tools but does not shy away from freemium services.

Introduction

Decentralized exchanges (DEXs) often exhibit price discrepancies due to the impact of large trades. This system aims to take advantage of these discrepancies through flash loans, which allow borrowing large amounts of cryptocurrency without collateral, provided the loan is repaid within the same transaction.

Key features of this system include:

  • Price Arbitrage: Capitalize on price misalignment's between exchanges. Large trades can create imbalances in liquidity pools, distorting prices and causing slippage.
  • Smart Contract Relay: Utilize a Solidity smart contract to act as a relay between the controller and the exchanges, ensuring efficient and secure transactions.
  • Modular and Extensible Design: Built with a modular architecture, allowing for easy integration of additional features and support for other exchanges.

Tech Stack

  • Node.js - JavaScript runtime.
  • TypeScript - Typed superset of JavaScript.
  • Hardhat - Ethereum development environment.
  • Alchemy - Ethereum node provider.
  • Solidity - A programming language for writing smart contracts.
  • Uniswap v3 - Decentralized exchange on Binance Smart Chain.

Outline

Strategy

Resources

Getting Started

Prerequisites

Ensure you have the following installed:

Additionally, you will need:

  • An Ethereum wallet with sufficient funds to cover gas fees. You can create a new wallet using the script in the scripts folder.
  • An account on Alchemy with a new project created to obtain the API key.
  • Deployed smart contracts on the Polygon network. The Remix IDE is a good tool to perform the deployment.

Installation

  1. Clone the repository:

    git clone https://github.com/jorgejch/dex-arbitrage.git
    cd dex-arbitrage
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory and add your configuration as in the .env.example file.

Usage

  1. Compile the TypeScript files:

    npm run build
  2. Run the deployment script:

    npm run start

Disclaimer

This repository is for educational and informational purposes only. It is not investment advice or a recommendation to buy or sell any financial instrument. The information provided here should not be used as the basis for any investment decision. Always conduct your own research and consult with a qualified financial advisor before making any investment decisions. The authors and contributors are not responsible for any financial losses or damages incurred as a result of using this software. The contents are subject to change without notice.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

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