TypeScript SDK

The @yoorquezt/sdk-mev package provides an EIP-1193 compatible provider wrapper that intercepts eth_sendRawTransaction calls and routes them through YoorQuezt's MEV protection pipeline. It also includes a MEVGatewayClient for direct WebSocket interaction with the MEV engine.

Installation

npm install @yoorquezt/sdk-mev

Features

  • EIP-1193 compatible -- works as a drop-in provider for ethers.js, viem, and web3.js
  • Automatic interception -- eth_sendRawTransaction is intercepted and protected; all other methods are proxied
  • MEV rebates -- 90% of captured backrun value is rebated to the originating wallet
  • Gateway client -- MEVGatewayClient for direct WebSocket JSON-RPC 2.0 interaction
  • Streaming -- subscribe to real-time auction, bundle, and protection events
  • Multi-chain -- supports Ethereum, Arbitrum, Base, Optimism, BSC, Polygon, ZkSync, Solana, and more
  • TypeScript-first -- full type definitions included

Configuration Options

OptionTypeDefaultDescription
apiKeystring--Your YoorQuezt API key (required)
chainIdnumber1Target chain ID
rpcUrlstringhttps://rpc.yoorquezt.io/v1/rpc/ethereumYoorQuezt RPC endpoint
timeoutnumber30000Request timeout in milliseconds
retriesnumber3Number of retry attempts on transient failures
rebateAddressstringsigner addressAddress to receive MEV rebates (defaults to tx signer)

EIP-1193 Provider (ethers.js)

import { YoorQueztProvider } from "@yoorquezt/sdk-mev";
import { ethers } from "ethers";

// Create the protected provider
const yqProvider = new YoorQueztProvider({
  apiKey: "YOUR_API_KEY",
  chainId: 1,
});

// Wrap in ethers BrowserProvider
const provider = new ethers.BrowserProvider(yqProvider);
const signer = await provider.getSigner();

// Send a transaction -- automatically MEV-protected
const tx = await signer.sendTransaction({
  to: "0xRecipient",
  value: ethers.parseEther("1.0"),
});

console.log("Transaction hash:", tx.hash);
await tx.wait();

Gateway Client (WebSocket)

For direct interaction with the MEV engine via WebSocket:

import { MEVGatewayClient } from "@yoorquezt/sdk-mev";

const gw = new MEVGatewayClient("ws://localhost:9099/ws", {
  apiKey: process.env.YQMEV_API_KEY,
});

// Submit bundle
const result = await gw.submitBundle({
  txs: ["0xsigned1", "0xsigned2"],
  blockNumber: 19482300,
  chain: "ethereum",
});
console.log("Bundle hash:", result.bundleHash);

// Subscribe to auction events
const sub = await gw.subscribe("auction");
sub.on("data", (event) => {
  console.log("Auction event:", event);
});

Full Example

import { YoorQueztProvider } from "@yoorquezt/sdk-mev";
import { ethers } from "ethers";

async function main() {
  // 1. Create YoorQuezt provider
  const yqProvider = new YoorQueztProvider({
    apiKey: process.env.YQ_API_KEY,
    chainId: 1,
    timeout: 60000,
  });

  // 2. Create ethers provider and signer
  const provider = new ethers.BrowserProvider(yqProvider);
  const signer = await provider.getSigner();

  console.log("Signer address:", await signer.getAddress());

  // 3. Send a protected transaction
  const tx = await signer.sendTransaction({
    to: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    value: ethers.parseEther("0.1"),
  });

  console.log("Submitted:", tx.hash);
  const receipt = await tx.wait();
  console.log("Confirmed in block:", receipt.blockNumber);

  // 4. Check protection status via JSON-RPC
  const status = await yqProvider.request({
    method: "mev_getProtectStatus",
    params: [tx.hash],
  });

  console.log("Protection status:", status);
}

main().catch(console.error);
Edit this page