The Go SDK provides a WebSocket JSON-RPC 2.0 client for interacting with the YoorQuezt MEV engine. It supports concurrent calls, atomic request IDs, and subscription channels for real-time event streaming.
Installation
go get github.com/yoorquezt-labs/yoorquezt-sdk-mev-go
Features
- WebSocket JSON-RPC 2.0 -- persistent connection with concurrent call support
- Atomic request IDs -- thread-safe ID generation for parallel requests
- Subscriptions -- channel-based subscription system for real-time events
- Automatic reconnection -- configurable reconnect with exponential backoff
- Context support -- all methods accept
context.Contextfor cancellation and timeouts
Available Methods
The client exposes the following JSON-RPC methods via the gateway:
Bundle Operations:
mev_sendBundle-- submit a bundle for MEV extractionmev_getBundle-- query bundle status by IDmev_simulateBundle-- simulate a bundle without submittingmev_simulateTx-- simulate a single transactionmev_listBundles-- list stored bundles
Protected Transactions:
mev_protectTx-- submit a transaction with MEV protectionmev_getProtectStatus-- query protection statusmev_getProtectRebates-- query accumulated rebates
Auction:
mev_getAuction-- query current auction state
Intent Operations:
mev_submitIntent-- submit an intentmev_getIntent-- query intent by IDmev_submitSolution-- submit a solver solutionmev_getSolutions-- list solutions for an intentmev_registerSolver-- register as a solvermev_listSolvers-- list registered solvers
Relay Operations:
mev_relayRegister-- register a relaymev_relayList-- list connected relaysmev_relayStats-- relay marketplace statisticsmev_relayGet-- get relay by ID
Query / System:
mev_listBlocks-- list recent blocksmev_getBlock-- get block by IDmev_health-- health checkmev_authStats-- authentication statisticsmev_simCacheStats-- simulation cache statisticsmev_orderflowSummary-- orderflow summary
Aliases (yq_ prefix):
yq_getProtectionStatus-- alias formev_getProtectStatusyq_getRebateHistory-- alias formev_getProtectRebatesyq_getStats-- OFA statistics
Subscription Topics
| Topic | Description |
|---|---|
auction | Real-time auction events: new bids, auction results, winning bundles |
protect | Protection events: MEV detected, mitigated, rebates accumulated |
blocks | New block events with included bundles and MEV statistics |
mempool | Mempool activity: new transactions, pending bundles |
intents | Intent lifecycle events: submitted, solving, filled, expired |
Subscribe via mev_subscribe / mev_unsubscribe (or yq_subscribe / yq_unsubscribe).
Code Example
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/yoorquezt-labs/yoorquezt-sdk-mev-go"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// Connect to the gateway
c, err := yqmev.Dial(ctx, "ws://localhost:9099/ws", client.Options{
APIKey: "YOUR_API_KEY",
ReconnectBackoff: 2 * time.Second,
MaxReconnects: 5,
})
if err != nil {
log.Fatalf("failed to connect: %v", err)
}
defer c.Close()
// Submit a protected transaction
var txStatus jsonrpc.TransactionStatus
err = c.Call(ctx, "mev_protectTx", &txStatus, jsonrpc.ProtectedTxParams{
RawTx: "0x02f8...",
ChainID: 1,
})
if err != nil {
log.Fatalf("send protected tx failed: %v", err)
}
fmt.Printf("Transaction: %s, Protected: %v\n", txStatus.TxHash, txStatus.Protected)
// Submit a bundle
var bundleResult jsonrpc.BundleResult
err = c.Call(ctx, "mev_sendBundle", &bundleResult, jsonrpc.BundleParams{
Txs: []string{"0x02f8...", "0x02f8..."},
BlockNumber: "0x10a3b2c",
MinTimestamp: 0,
MaxTimestamp: 0,
})
if err != nil {
log.Fatalf("send bundle failed: %v", err)
}
fmt.Printf("Bundle ID: %s\n", bundleResult.BundleID)
// Subscribe to auction events
auctionCh, subID, err := c.Subscribe(ctx, "auction")
if err != nil {
log.Fatalf("subscribe failed: %v", err)
}
defer c.Unsubscribe(ctx, subID)
fmt.Println("Listening for auction events...")
for {
select {
case event := <-auctionCh:
fmt.Printf("Auction event: %s\n", event.Method)
case <-ctx.Done():
fmt.Println("Context cancelled, shutting down")
return
}
}
}
Querying Rebates
// Check accumulated rebates
var rebates jsonrpc.RebateResponse
err = c.Call(ctx, "mev_getProtectRebates", &rebates, map[string]string{
"originator_id": "0xYourAddress",
})
if err != nil {
log.Fatalf("get rebates failed: %v", err)
}
fmt.Printf("Rebate balance: %s ETH\n", rebates.TotalRebate)