Real-time bidding API scaffold for MevWallet transactions

Related tags

Web programming rtb
Overview

MevWallet RTB API

This repo provides a standard interface for a real-time bidding API. Searchers run the API to provide bids to users. The bid represents the Searcher's desired tip for including that transaction in their current bundle. Users SHOULD accept one or more bids, and respond with signed MevTx objects to /bundle

Implementing the RTB API

This crate provides a webserver wrapping a SearcherService. The service has a minimal interface, and can encapsulate arbitrary logic.

pub trait SearcherService {
    async fn bid(&self, tx: &MevTxBuilder) -> eyre::Result<responses::BidResponse>;

    async fn bundle(
        &self,
        tx: &SignedMevTx,
        auth: Option<H256>,
    ) -> eyre::Result<responses::BundleResponse>;
}

The bid function implements the /bid endpoint. It accepts a partial MevTx and returns a bid, or a rejection. If the user is willing to accept a bid, they sign the transaction and call the /bundle endpoint. Bids are issued against a specific block, and may include an auth token. This function SHOULD simulate MEV extraction and respond to the user with a quote for inclusion. This function MUST respond with a proposed tip, or a rejection.

The bundle function implements the /bundle endpoint. It accepts a signed MEV transaction, and appends it to a bundle. The searcher SHOULD re-simulate the transaction against their current bundle state to ensure it is still profitable. The Searcher MUST respond with either a status, a rejection, or a new bid.

Once the trait has been implemented, the library handles spinning up a server for it. The Searcher SHOULD put this behind a rate limiter, or other reverse proxy

#[tokio::main]
fn main() {
    // instantiate your bidding service
    let my_bidder = MyBidder::new();
    // Your bidder, IP and Port
    rtb::serve(my_bidder, ([0, 0, 0, 0], 80)).await
}

Writing a bidding service

Bidding services SHOULD tap into your MEV simulation architecture, either directly or via IPC. You are free to add arbitrary logic or actions.

A simple flow might be:

  • Choose a profit margin %
  • Choose a minimum inclusion fee
  • Simulate the transaction against your current bundle state
    • Reject reverting transactions
    • Output total extractable MEV
  • If MEV is positive:
    • Quote -1 - (total_extractable - (1 - profit_margin))
  • If MEV is 0:
    • Quote the minimum inclusion fee

Routes

POST /bid
POST /bundle
GET /healthcheck

All routes follow the convention { "response": ... }

/bid

A user posts a partial MEV transaction. If the TX is biddable, the server MUST respond with a bid. The bid MUST conform to one of the 4 formats below

POST: A partially constructed MEV transaction as JSON RESPONSES:

{
    "response": {
        "accept": {
            "tip": "0x1234", // I256
            "block": "0x1234" // U256
        }
    }
}

{
    "response": {
        "acceptWithAuth": {
            "tip": "0x1234", // I256
            "block": "0x1234", // U256
            "token": "0x1234" // H256
        }
    }
}

{
    "response": "decline"
}

{
    "response": {
        "incomplete": "details of missing info" // String
    }
}

/bundle

POST: A signed, executable MEV transaction as JSON RESPONSES:

{
    "response": "bundled"
}

{
    "response": {
        "tipTooLow": "0x1234" // I256
    }
}

{
    "response": {
        "newBid": {...} // any valid /bid response body
    }
}

{
    "response": "unknownToken"
}

{
    "response": {
        "rejection": "rejection message"
    }
}
You might also like...
Scratch-Containerised Rust GraphQL-API using Dataloaders

Dockerize Graphql Rust More current version at https://github.com/jayy-lmao/rust-cult-graphql-server This project is currently for demonstrating the u

A Rust Boilerplate server with GraphQL API, Diesel, PostgreSQL, session authentication and JWT
A Rust Boilerplate server with GraphQL API, Diesel, PostgreSQL, session authentication and JWT

Canduma rust Graphql A Rust authentication server with GraphQL API, Diesel, PostgreSQL session authentication and JWT This repository contains a Graph

Implementation of the RealWorld backend API spec in Actix, Rust's powerful actor system and most fun web framework.
Implementation of the RealWorld backend API spec in Actix, Rust's powerful actor system and most fun web framework.

Actix codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API. ❗ (2021/05/13) This cod

Rust Rest API Stack with User Management
Rust Rest API Stack with User Management

A secure-by-default rest api stack implemented with hyper, tokio, bb8 and postgres. This project is focused on providing end-to-end encryption by default for 12-factor applications. Includes a working user management and authentication backend written in postgresql with async S3 uploading for POST-ed data files.

Fastest autocomplete API written in rust 🦀

rust-autocomplete-api fastest* autocomplete API written in rust 🦀 *probably Run it locally cargo build --release ./target/release/autocomplete-api-po

A customizable, simple and easy to use json REST API consumer

JACK is a generic JSON API client. It is useful to interact with APIs from multiple services such as Google and Twitter

Print Apple WeatherKit REST API weather conditions and hourly/daily foreacast to the console.
Print Apple WeatherKit REST API weather conditions and hourly/daily foreacast to the console.

weatherkit-rust A Rust CLI program to print current conditions and daily/hourly forecast to the console. Please read authorization.md as you need an A

Rust Rocket MongoDB token-authorization REST API boilerplate

Rust Rocket MongoDB token-auth REST API boilerplate In this repository, you can find backend Rust rocket mongodb rest-api boilerplate with token autho

RESTful Todo API with Actix-web and SeaORM. Documented by swagger-ui

RESTful Todo RESTful Todo API with Actix and SeaORM. Documented by swagger-ui Prerequisites Rust Usage Clone the repository and run the following comm

Owner
Blunt Instruments
smashing solutions to difficult problems
Blunt Instruments
The goal of this repository is to have a real world template of a Rust backend using Axum, Diesel, etc.

Axum Diesel Real-World Example A modular Rust backend template based on the Domain-Driven Design (DDD) architecture, utilizing the Axum and Diesel fra

Quentin Piot 11 Sep 22, 2023
REST API server that abstracts the need to write CRUD methods by exposing a standardized API to interact with a Postgres database

Basiliq Exposing a Postgres database via a REST API that follows the JSON:API specs. All in all, a tasty API. What is Basiliq Quickstart Ready to use

Basiliq 54 Apr 21, 2022
A secure and efficient gateway for interacting with OpenAI's API, featuring load balancing, user request handling without individual API keys, and global access control.

OpenAI Hub OpenAI Hub is a comprehensive and robust tool designed to streamline and enhance your interaction with OpenAI's API. It features an innovat

Akase Cho 30 Jun 16, 2023
Rust Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.

Rust Embed Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev. Y

Peter 1k Jan 5, 2023
Rust I18n is use Rust codegen for load YAML file storage translations on compile time, and give you a t! macro for simply get translation texts.

Rust I18n Rust I18n is use Rust codegen for load YAML file storage translations on compile time, and give you a t! macro for simply get translation te

Longbridge 73 Dec 27, 2022
The simplest build-time framework for writing web apps with html templates and typescript

Encoped A build-time fast af tool to write static apps with html and TypeScript Features Template-based ESLint, Prettier and Rollup integration No ext

null 1 Dec 11, 2021
Grape is a REST-like API framework for Ruby

Grape is a REST-like API framework for Ruby. It's designed to run on Rack or complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily develop RESTful APIs. It has built-in support for common conventions, including multiple formats, subdomain/prefix restriction, content negotiation, versioning and much more.

Ruby Grape 9.7k Jan 2, 2023
Rust implementation of the `URLPattern` web API

urlpattern This crate implements the URLPattern web API in Rust. We aim to follow the specification as closely as possible. Contributing We appreciate

Deno Land 40 Dec 14, 2022
A pure Rust implementation of the Web Local Storage API, for use in non-browser contexts

Rust Web Local Storage API A Rust implementation of the Web LocalStorage API, for use in non-browser contexts About the Web Local Storage API MDN docs

RICHΛRD ΛNΛYΛ 10 Nov 28, 2022
An tiny web API for @QuarryProtocol

Warlock Warlock is a tiny web API layer around Quarry Protocol and has endpoints to deserialize Quarry accounts like quarries, miners, and rewarders t

Rohan Kapur 2 May 16, 2022