101

Automated Copy-Trading

Ethereum Copy-Trading Bot that lets you trade like the pros, and frontrun them.

Moonwave's Ethereum Copy-Trading Bot

Our Copy-Trading Bot for Ethereum is designed to help us trade like the professionals. Leveraging the transparent nature of blockchain technology, we meticulously analyze various performance indicators of profitable traders. These indicators include not only their PnL but also their risk management strategies and other vital trading metrics.

having open_trade_volume_usd > 100000
and last_open_block_time >= '{{last_trade_after}}'
and open_vault_cnt > 30
and net_pl > 100000
and win_ratio > 60

After identifying these top-performing traders, our bot aims to replicate their successes.

Features

Ethereum Node and Provider Reliability for Optimal Transaction Monitoring

To ensure the quickest and most reliable access to transaction data, we operate on a multi-layered infrastructure.

  • we run our own Ethereum node, giving us direct access to monitor the mempool and observe pending transactions. This native access enables us to frontrun market movements by being among the first to witness transactions before they are confirmed and added to the blockchain.

  • In addition, we leverage the infrastructure of top-tier providers like QuickNode and Alchemy. These services supplement our node's data feed, providing an additional layer of reliability and speed. By combining our local node with these enterprise-grade providers, we're equipped to retrieve pending transactions in the most efficient manner possible.

import { Alchemy, Network, Wallet as AlchemyWallet } from "alchemy-sdk";
import { ethers } from "ethers";

This hybrid approach affords us a wider margin of maneuver for performing simulations and calculations before executing trades. With this setup, we can assure the inclusion of our transaction within the same block, maximizing our chances of success.

Multi-Protocol Support for DeFi Trading

  • Our bot is designed to be a versatile tool in the DeFi landscape. It can interface with a variety of trading platforms and protocols. From automated market makers like Uniswap (supporting both V2 and V3, as well as the Universal Router) to margin trading platforms like Dydx and GMX, and even liquidity aggregators like 1inch.

  • The bot adapt trade sizes and routes according to the copied trader's portfolio size, all the while optimizing for minimal transaction fees and slippage.

Safety Measures: Guardrails for Secure Trading

Trading in the decentralized world comes with its own set of unique challenges and risks, including the infamous "rug pulls" and honeypot traps. Our bot doesn't take these lightly. Before jumping into any trade, it conducts a series of robust checks.

  • we simulate the transaction off-chain to ensure the trade is actually feasible. This simulation gives us critical information on potential roadblocks like high sales taxes or a disproportionate supply held by a single entity, which could indicate a risky investment.
// Conditions to check
const sellTax = tokenData.simulationResult.sellTax;
const buyTax = tokenData.simulationResult.buyTax;
const holders = tokenData.holderAnalysis.holders;
const isHoneypot = tokenData.honeypotResult.isHoneypot;
const simulationSuccess = tokenData.simulationSuccess;
const hasProxyCalls = GetContractVerification.data.HasProxyCalls;
const isVerified = Object.values(GetContractVerification.data.Contracts)[0];
  • We analyze the smart contract to which we're sending the transaction, looking for red flags such as abnormal code behavior or the presence of known vulnerabilities.
// Conditions to check
const conditions = {
  anti_whale_modifiable: "0",
  can_take_back_ownership: "0",
  cannot_buy: "0",
  honeypot_with_same_creator: "0",
  is_anti_whale: "0",
  is_blacklisted: "0",
  is_honeypot: "0",
  personal_slippage_modifiable: "0",
  slippage_modifiable: "0",
  trading_cooldown: "0",
  transfer_pausable: "0",
  is_open_source: "1",
};

======= To ensure the quickest and most reliable access to transaction data, we operate on a multi-layered infrastructure.

  • we run our own Ethereum node, giving us direct access to monitor the mempool and observe pending transactions. This native access enables us to frontrun market movements by being among the first to witness transactions before they are confirmed and added to the blockchain.

  • In addition, we leverage the infrastructure of top-tier providers like QuickNode and Alchemy. These services supplement our node's data feed, providing an additional layer of reliability and speed. By combining our local node with these enterprise-grade providers, we're equipped to retrieve pending transactions in the most efficient manner possible.

This hybrid approach affords us a wider margin of maneuver for performing simulations and calculations before executing trades. With this setup, we can assure the inclusion of our transaction within the same block, maximizing our chances of success.

Multi-Protocol Support for DeFi Trading

  • Our bot is designed to be a versatile tool in the DeFi landscape. It can interface with a variety of trading platforms and protocols. From automated market makers like Uniswap (supporting both V2 and V3, as well as the Universal Router) to margin trading platforms like Dydx and GMX, and even liquidity aggregators like 1inch.

  • The bot adapt trade sizes and routes according to the copied trader's portfolio size, all the while optimizing for minimal transaction fees and slippage. This meticulous approach ensures consistently profitable trades, leveraging the broad spectrum of DeFi protocols available.

SSafety Measures: Guardrails for Secure Trading

Trading in the decentralized world comes with its own set of unique challenges and risks, including the infamous "rug pulls" and honeypot traps. Our bot doesn't take these lightly. Before jumping into any trade, it conducts a series of robust checks.

  • we simulate the transaction off-chain to ensure the trade is actually feasible. This simulation gives us critical information on potential roadblocks like high sales taxes or a disproportionate supply held by a single entity, which could indicate a risky investment.

  • We analyze the smart contract to which we're sending the transaction, looking for red flags such as abnormal code behavior or the presence of known vulnerabilities.

  • All these safety measures aim to prevent disastrous scenarios where we end up buying tokens that we can't sell later. It's not just about copying the pros; it's about doing it smartly and safely. With this multi-layered approach to safety, we make sure that each trade isn't just a shot in the dark, but a well-considered move.

In-Block Trading with Flashbots: A Layer of Certainty in Uncertain Markets

To secure our edge in trading, we turn to Flashbots for in-block execution. Flashbots provide a backchannel to Ethereum miners, allowing us to bypass the public mempool and have our transactions included directly in the next block.

  • We bundle not just the buying or selling action, but also any necessary approvals for the token and protocols involved. The bundle is rigorously tested and simulated to prevent any possibility of a 'revert', making our transaction highly reliable.
let txn =
    {
      from: wallet.address,
      to: ROUTER_ADDRESS,
      value: ethers.toQuantity(amountIn),
      data: data,
    }
 
let result = await simulateWithAlchemyBuy(txn, block).catch(console.error);
  • These bundles are then dispatched to multiple block builders. By doing this, we elevate our confidence index to as high as 90% for the transaction to be included in the next block.
flashbotRelays = [
  "https://relay.flashbots.net",
  "https://builder0x69.io/", 
  "wss://mev.api.blxrbdn.com/ws",
  "https://rpc.beaverbuild.org/",
  "https://rsync-builder.xyz/",
  "https://eth-builder.com",
  "https://api.securerpc.com/v1",
  "https://rpc.lightspeedbuilder.info/",
  "https://rpc.f1b.io",
  "https://rpc.titanbuilder.xyz",
  "https://rpc.payload.de"
];

To further ensure our position in the block, we calculate the most optimal tip' to give to these block builders, acting as an extra incentive for them.

To secure our edge in trading, we turn to Flashbots for in-block execution. Flashbots provide a backchannel to Ethereum miners, allowing us to bypass the public mempool and have our transactions included directly in the next block.

  • We bundle not just the buying or selling action, but also any necessary approvals for the token and protocols involved. The bundle is rigorously tested and simulated to prevent any possibility of a 'revert', making our transaction highly reliable.

  • These bundles are then dispatched to multiple block builders. By doing this, we elevate our confidence index to as high as 90% for the transaction to be included in the next block. To further ensure our position in the block, we calculate the most optimal 'tip' to give to these block builders, acting as an extra incentive for them.

How It Works: The Inner Workings of Our Copy-Trading Bot

  1. Mempool Scanning: The bot continuously scans the Ethereum mempool. This real-time access lets us identify promising transactions and potential trades to copy before they are publicly confirmed.
  2. Protocol and Trader Identification: The bot recognizes transactions across a wide array of DeFi protocols. It further filters these transactions based on the trading profiles of the traders we aim to copy.
  3. Transaction verification: Leveraging advanced analytics, the bot calculates the potential profitability of copying a particular trade. It factors in variables like slippage, gas fees, and trader history.
  4. Safety Checks: Prior to execution, the bot performs a multitude of robust verifications. These include off-chain transaction simulations to identify rug pulls, honeypots, and other possible pitfalls like high sales taxes or a large portion of the supply being held by a single entity.
  5. Transaction Copying and Flashbots: The bot bundles the verified transactions and necessary token approvals into Flashbots bundles. These are then dispatched to multiple block builders to secure a high confidence index for in-block execution.
  6. Transaction Execution: The bot carries out the trade, optimizing for gas and giving tips to block builders to ensure the transaction's timely inclusion in the next block.

Tools Utilized

  • Programming Languages: Primarily built using JavaScript and Solidity for smart contracts.

  • APIs and SDKs: Extensive use of QuickNode and Alchemy APIs for node services, as well as various SDKs from supported protocols to interact with their smart contracts effectively.

  • Data Analytics: Dune Analytics is employed to track and analyze trading patterns and other on-chain metrics.

  • Transaction Execution: Flashbots for in-block trade execution, improving both speed and reliability of our trades.

By combining these tools and features, our bot aims to offer a one-stop solution for Ethereum copy-trading that is not only fast but also secure and efficient.