flashbot

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 15 Imported by: 0

README

For usage and description see the test files and https://pkg.go.dev/github.com/cryptoriums/flashbot

Lets work together if you have some good flashbot MEV strategies.
See my github profile for contact details.

Documentation

Overview

Package flashbot provides a structured way to send TX to the flashbot relays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	URL                string
	SupportsSimulation bool
	MethodCall         string
	MethodSend         string
	CustomHeaders      map[string]string
}

func DefaultApi

func DefaultApi(netID int64) (*Api, error)

type BundleStats

type BundleStats struct {
	IsSimulated    bool
	IsHighPriority bool
	SimulatedAt    time.Time
	SubmittedAt    time.Time
	SentToMinersAt time.Time
}

type BundleUserStats

type BundleUserStats struct {
	IsHighPriority       bool   `json:"is_high_priority,omitempty"`
	AllTimeMinerPayments string `json:"all_time_miner_payments,omitempty"`
	AllTimeGasSimulated  string `json:"all_time_gas_simulated,omitempty"`
	Last7dMinerPayments  string `json:"last_7d_miner_payments,omitempty"`
	Last7dGasSimulated   string `json:"last_7d_gas_simulated,omitempty"`
	Last1dMinerPayments  string `json:"last_1d_miner_payments,omitempty"`
	Last1dGasSimulated   string `json:"last_1d_gas_simulated,omitempty"`
}

type CancelPrivateTransactionResponse

type CancelPrivateTransactionResponse struct {
	Error  `json:"error,omitempty"`
	Result bool `json:"result,omitempty"`
}

type Error

type Error struct {
	Code    int
	Message string
}

type Flashbot

type Flashbot struct {
	// contains filtered or unexported fields
}

func (*Flashbot) Api

func (self *Flashbot) Api() *Api

func (*Flashbot) CallBundle

func (self *Flashbot) CallBundle(
	ctx context.Context,
	txsHex []string,
	_blockNumState uint64,
) (*Response, error)

func (*Flashbot) CancelPrivateTransaction

func (self *Flashbot) CancelPrivateTransaction(ctx context.Context, txHash common.Hash) (*CancelPrivateTransactionResponse, error)

func (*Flashbot) GetBundleStats

func (self *Flashbot) GetBundleStats(
	ctx context.Context,
	bundleHash string,
	blockNum uint64,
) (*ResultBundleStats, error)

func (*Flashbot) GetUserStats

func (self *Flashbot) GetUserStats(
	ctx context.Context,
	blockNum uint64,
) (*ResultUserStats, error)

func (*Flashbot) PrvKey

func (self *Flashbot) PrvKey() *ecdsa.PrivateKey

func (*Flashbot) SendBundle

func (self *Flashbot) SendBundle(
	ctx context.Context,
	txsHex []string,
	blockNum uint64,
) (*Response, error)

func (*Flashbot) SendPrivateTransaction

func (self *Flashbot) SendPrivateTransaction(ctx context.Context, txHex string, blockNum uint64, fast bool) (*SendPrivateTransactionResponse, error)

func (*Flashbot) SetKey

func (self *Flashbot) SetKey(prvKey *ecdsa.PrivateKey) error

func (*Flashbot) SimulateBundle

func (self *Flashbot) SimulateBundle(
	ctx context.Context,
	txsHex []string,
	blockNum uint64,
) (*SimBundleResult, error)

type Flashboter

type Flashboter interface {
	SendPrivateTransaction(ctx context.Context, txHex string, blockNum uint64, fast bool) (*SendPrivateTransactionResponse, error)
	CancelPrivateTransaction(ctx context.Context, txHash common.Hash) (*CancelPrivateTransactionResponse, error)
	SendBundle(ctx context.Context, txsHex []string, blockNum uint64) (*Response, error)
	CallBundle(ctx context.Context, txsHex []string, blockNumState uint64) (*Response, error)
	GetBundleStats(ctx context.Context, bundleHash string, blockNum uint64) (*ResultBundleStats, error)
	GetUserStats(ctx context.Context, blockNum uint64) (*ResultUserStats, error)
	SimulateBundle(ctx context.Context, txsHex []string, blockNum uint64) (*SimBundleResult, error)
	Api() *Api
}

func New

func New(prvKey *ecdsa.PrivateKey, api *Api) (Flashboter, error)

func NewAll

func NewAll(netID int64, prvKey *ecdsa.PrivateKey, additional ...*Api) ([]Flashboter, error)

func NewMulti

func NewMulti(netID int64, prvKey *ecdsa.PrivateKey, apis ...*Api) ([]Flashboter, error)

type Inclusion

type Inclusion struct {
	Block    string `json:"block"`
	MaxBlock string `json:"maxBlock"`
}

type Metadata

type Metadata struct {
	CoinbaseDiff      string
	EthSentToCoinbase string
	GasFees           string
}

type ParamsCall

type ParamsCall struct {
	Txs           []string `json:"txs,omitempty"`
	BlockNum      string   `json:"blockNumber,omitempty"`
	StateBlockNum string   `json:"stateBlockNumber,omitempty"`
}

type ParamsCancelPrivateTransaction

type ParamsCancelPrivateTransaction struct {
	TxHash string `json:"txHash,omitempty"`
}

type ParamsPrivateTransaction

type ParamsPrivateTransaction struct {
	Tx             string `json:"tx,omitempty"`
	МaxBlockNumber string `json:"maxBlockNumber,omitempty"`
	Preferences    struct {
		Fast bool `json:"fast,omitempty"`
	} `json:"preferences,omitempty"`
}

type ParamsSend

type ParamsSend struct {
	BlockNum string   `json:"blockNumber,omitempty"`
	Txs      []string `json:"txs,omitempty"`
}

type ParamsStats

type ParamsStats struct {
	BlockNum   string `json:"blockNumber,omitempty"`
	BundleHash string `json:"bundleHash,omitempty"`
}

type Response

type Response struct {
	Error  `json:"error,omitempty"`
	Result `json:"result,omitempty"`
}

type Result

type Result struct {
	BundleGasPrice string
	BundleHash     string
	Metadata
	Results []TxResult
}

type ResultBundleStats

type ResultBundleStats struct {
	Error
	Result BundleStats
}

type ResultUserStats

type ResultUserStats struct {
	Error
	Result BundleUserStats
}

type SendPrivateTransactionResponse

type SendPrivateTransactionResponse struct {
	Error  `json:"error,omitempty"`
	Result string `json:"result,omitempty"`
}

type SimBundleResult

type SimBundleResult struct {
	Result struct {
		Error           string `json:"error,omitempty"`
		Success         bool   `json:"success"`
		StateBlock      string `json:"stateBlock"`
		MevGasPrice     string `json:"mevGasPrice"`
		Profit          string `json:"profit"`
		RefundableValue string `json:"refundableValue"`
		GasUsed         string `json:"gasUsed"`
		Logs            []any  `json:"logs"`
	} `json:"result"`
	Error `json:"error,omitempty"`
}

type SimTx

type SimTx struct {
	Tx        string `json:"tx"`
	CanRevert bool   `json:"canRevert"`
}

type SimulateBundleParams

type SimulateBundleParams struct {
	Inc     Inclusion `json:"inclusion"`
	Body    []SimTx   `json:"body"`
	Version string    `json:"version"`
}

type Tx

type Tx struct {
	From common.Address `json:"from,omitempty"`
	To   common.Address `json:"to,omitempty"`
	Data []byte         `json:"data,omitempty"`
}

type TxResult

type TxResult struct {
	Metadata
	FromAddress string
	GasPrice    string
	TxHash      string
	Error       string
	Revert      string
	GasUsed     uint64
}

Directories

Path Synopsis
scripts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL