Skip to content

Conversation

@Neros0
Copy link
Contributor

@Neros0 Neros0 commented Jan 22, 2025

This pull request introduces a complete implementation of the Arbitrage.sol smart contract, designed to leverage Balancer's flash loans and Uniswap V3 for profitable arbitrage opportunities. Additionally, this PR includes updates to the project dependencies and configurations to support the new functionality.


Key Changes

  1. New Contract: Arbitrage.sol

    • Implements a robust arbitrage mechanism utilizing:
      • Balancer Vault Flash Loans for obtaining temporary liquidity.
      • Uniswap V3 Router for token swaps.
    • Core functionalities:
      • Flash Loan Execution: Borrows tokens from Balancer.
      • Multi-Hop Arbitrage: Swaps tokens in two steps to maximize profit.
      • Profit Transfer: Returns borrowed tokens and sends profits to the owner.
    • Features:
      • Struct-based trade configurations for flexibility.
      • Token approvals and optimized swap logic.
  2. Removed Legacy Contracts

    • Deleted outdated files: ArbitrageMaker.sol and FlashLoanTx.sol, consolidating their logic into Arbitrage.sol.
  3. Dependencies Added

    • Submodules integrated for project extensibility:
      • Balancer V2 Monorepo: For flash loan interactions.
      • OpenZeppelin Contracts: For token standards and utilities.
      • Uniswap V3 Periphery and Core: For swap functionality.
  4. Configuration Updates

    • .gitmodules:
      • Added submodules for Balancer, OpenZeppelin, and Uniswap V3 repositories.
    • foundry.toml:
      • Updated remappings to include the newly added dependencies.
  5. Code Optimizations

    • Streamlined swap logic for Uniswap V3 transactions using ISwapRouter.
    • Enhanced contract modularity with internal helper functions.

Motivation

The new Arbitrage.sol contract simplifies and consolidates the arbitrage logic, reducing code redundancy while enhancing functionality. By leveraging Balancer and Uniswap's capabilities, the contract ensures efficient and profitable trades. Removing legacy files also improves project maintainability.


Technical Highlights

  • Balancer Flash Loans:

    • Utilizes the Balancer Vault for flash loans, enabling the contract to operate without upfront capital.
  • Uniswap V3 Swaps:

    • Implements precise token swapping via exactInputSingle for multi-hop arbitrage.
  • Profit Optimization:

    • Ensures that all excess tokens (profits) are securely transferred to the contract owner.

Testing and Validation

  • Tested contract deployment and function execution on local test networks.
  • Verified Balancer Vault and Uniswap V3 integration for seamless operations.
  • Conducted successful flash loan and multi-hop swaps with mock data.

Next Steps

  1. Perform integration testing with real-world token pairs and mainnet simulators.
  2. Extend functionality to handle multiple pools for more complex arbitrage scenarios.
  3. Create detailed documentation for developers and users.

Please review the changes and share feedback or suggestions for improvement.

@Neros0 Neros0 added enhancement New feature or request high-priority High priority task labels Jan 22, 2025
@Neros0 Neros0 self-assigned this Jan 22, 2025
@Neros0 Neros0 merged commit 05ab9ea into main Jan 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request high-priority High priority task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants