SkillAgentSearch skills...

RocketpoolExitArbitrage

No description available

Install / Use

/learn @0xtrooper/RocketpoolExitArbitrage
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Rocket Pool Distribute Arbitrage CLI Tool

WARNING
This software is an initial version and has not been thoroughly tested.
Use at your own risk. No guarantees are provided, and we assume no liability for any potential losses or damages resulting from its use. The flashloan functionality has been tested and there is reasonable level of confidence in its performance (e.g. Uniswap or Paraswap). The rETH burn bundle was tested on holesky (e.g. burn). Always review the code and run your own tests before using it in a production environment.


Overview

This repository contains a CLI (Command-Line Interface) tool designed to help capture arbitrage opportunities created by distributing minipools.
Whenever you call distribute on a pool, it sends the Rocket Pool share to the rETH contract, allowing more rETH to be burned in exchange for ETH.
When exiting minipools or claiming ETH, it is vital to check for arbitrage opportunities that would otherwise be captured by third parties.

The core objective is to leverage distribute calls in combination with rETH burn to capture potential arbitrage gains. This tool can also facilitate a flashloan for users who don't already hold rETH but want to capitalize on the arbitrage.

If you prefer not to run this CLI tool on your validator machine alongside the smartnode daemon—or if you don't have access to the smartnode (for example, when using a service like Allnodes) — you can use the --rpc=... flag and provide your node operator private key via --node-private-key. You can also use your Withdrawal Address instead, depending on what best suits your situation.

If you encounter any issues while using the tool, please open a GitHub issue so we can investigate and address it.

Why This Tool?

  • Scenario 1:
    If you already hold rETH, you can bundle the distribute action with an rETH burn to recive ETH at the protocol rate.
  • Scenario 2:
    If you don't hold rETH, you can use a flashloan to obtain rETH, perform the distribute and burn, then repay the loan—collecting any remaining ETH as profit.

Table of Contents

  1. Known Issues & Limitations
  2. Smart Contract
  3. Requirements
  4. Installation
  5. How to simulate
  6. Usage
  7. Configuration
  8. License

Known Issues & Limitations

  • Profit Checks with Multiple Pools
    When using Paraswap with low discounts and a high number of pools (via the --minipools flag), the tool does not perform individual profit checks for each pool. As a result, if the secondary rate crosses the primary rate, you may experience suboptimal profits. To maintain better profitability when discounts are low, it is advisable to limit the number of pools in a single call. Alternatively, you can use a Uniswap flash swap (--protocol=uniswap), but this approach is generally recommended only for smaller amounts—for example, exiting a single pool with 24 ETH.

Smart Contract

To execute a Flashswap with Uniswap and simultaneously burn rETH within a single transaction, I developed and deployed a custom smart contract. This contract is fully verified on Etherscan and can be viewed here. The contract provides two functions. The first (arb) executes a flash swap arbitrage call using Uniswap. The second (arbParaswap) allows users to take a flash loan via Morpho and perform an aggregated swap using Paraswap.

Key Features

  • No Approvals Required: The contract operates without needing any external approvals, simplifying its usage and reducing potential points of failure.
  • ETH-Free Transactions: The transaction process does not involve sending any ETH, minimizing exposure to ETH-related risks.
  • Profit Receiver: The user can decide to send the profit to an external wallet directly (withdrawal wallet by default).

Security Considerations

While the smart contract is designed with streamlined functionality and minimal interaction with external elements, it presents a low-risk profile. However, it is important to note that this contract has not undergone a formal security audit. Users are encouraged to review the contract code on Etherscan and exercise caution when interacting with it. Always act based on your best knowledge and understanding, ensuring you are comfortable with the contract's operations and potential risks before proceeding.


Requirements

  1. Go (version 1.22+ recommended)

    • You can download and install Go from the official Go Downloads page.
    • Refer to the official Getting Started guide for further instructions.
    • Earlier versions (e.g., 1.20, 1.21) may still work, but are not tested.
  2. Access to a Web3 Provider

    • Typically this is your Rocket Pool Eth1 client (e.g., Geth, Nethermind).
      • This can also be a WEB3 provider like infura. Set the full RPC URL with --rpc ...
    • Ensure that your Rocket Pool setup has Expose RPC Ports configured to Open to Localhost.
  3. Minipool Exit Completed

    • To finalize a minipool and distribute the full 32 ETH, the validator must be exited from the consensus layer.
    • Use the Rocket Pool command rocketpool m e to initiate the exit.
      • For Allnodes, users, click the 3 dots to the right of your minipool and select Voluntary exit.
    • Wait until the exit is fully processed and ETH is withdrawn from the consensus layer before proceeding with distribution.
    • You can monitor progress in your node logs or by using on-chain explorers to confirm that ETH has been returned.

Installation

For this initial version, no binaries are provided. You will need to install Go (1.22+ recommended) and build from source:

  1. Clone this repository:

    git clone https://github.com//0xtrooper/RocketpoolExitArbitrage.git && cd RocketpoolExitArbitrage    
    
  2. Build the binary:

    go build ./cmd/distribute/
    

    Note: This will download the necessary packages if they are not already cached.

  3. Run the CLI tool:

    ./distribute --help
    

How to simulate

You can use the --dry-run option to generate an example bundle without executing it. This option also displays the individual transactions involved. If you are using this tool to burn rETH, the transactions will always be printed. As that action is not time sensitive, take your time to confirm the transactions. They can be simulated using tools like Tenderly. Since the transactions are sent as part of an MEV bundle, their execution depends on the state resulting from the previous transactions. Therefore, it is essential to update the chain state while simulating. Our primary focus is on the final transaction, as it executes the arbitrage. Below is an example of the dry-run option:

Any profit will be sent to 0x1..2. This should be your withdrawal address.
Updated flashbots fee refund recipient to 0x1..2.
Current gas settings: base fee per gas is 5.13 gwei, tip is 0.01 gwei.
Sending transaction with a base fee per gas of 7.70 gwei for timely inclusion.

Calculated distribution amounts: 8.004334 ETH sent to NO, 24.007874 ETH sentto rETH contract.

If you want to use tenderly to simulate the arbitrage, you need to overwrite the state for the final transaction:
    - Set the ETH balance of the rETH contract (0xae78736Cd615f374D3085123A210448E74Fc6393) to 24007874061960000000

Calculated rETH to burn: Burning 21.327726 rETH for 24.007874 ETH at a primary ratio of 1.12566.

Uniswap: Swapping 23.882143 WETH to 21.327726 rETH at a secondary ratio of 1.11977 with a minimum profit of 0.125732. (pool 0x553e9C493678d8606d6a5ba284643dB2110Df823)

Simulated bundle (success):
    Expected profit after fees: 0.119380, with a tx fee of 0.006351
    Expected profit after arbitrage fees: 0.123230, with a tx fee of 0.002502 (interesting if you want to distribute regardless)

Dry run. Would have sent the following bundle:
Transaction 1:
    From: 0x8..C
    To: 0x7..4
    Value: 0
    Gas Limit: 500000
    Base Fee: 7698278631 (7.70 Gwei)
    Priority Fee: 5477241 (0.0055 Gwei)
    Nonce: 184
    Data: 5..0
Transaction 2:
    From: 0x8..C
    To: 0x228125B5519861a9176c1E4b12beeb2d41142D92
    Value: 0
    Gas Limit: 325000
    Base Fee: 7698278631 (7.70 Gwei)
    Priority Fee: 5477241 (0.0055 Gwei)
    Nonce: 185
    Data: a..9

As you can see, it prints the necessary state updates.

To simulate the arbitrage transaction, open Tenderly and navigate to the "Simulator" page. From there, create a new transaction. Enter the details for Transaction 2 as follows:

  1. First the To address.
  2. Select Mainnet as the network.
  3. Choose the Enter raw input data option and paste the Data from the output.

Example Inputs

Next, configure the state overwrite. Expand the State Overrides option on the right side and follow these steps:

  1. Click Add State Override.
  2. Select
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated6mo ago
Forks5

Languages

Go

Security Score

72/100

Audited on Sep 11, 2025

No findings