Documentation
¶
Index ¶
- Constants
- type BroadcastResponse
- type BroadcastResult
- type BuildernetGetDelayedRefundTotalsByRecipientParams
- type BuildernetGetDelayedRefundsParams
- type Bundle
- type BundleOption
- func WithExpirationBlock(block uint64) BundleOption
- func WithExpirationDurationInBlocks(duration uint64) BundleOption
- func WithMetadata(metadata MevSendBundleMetadata) BundleOption
- func WithPrivacy(privacy MevSendBundlePrivacy) BundleOption
- func WithValidity(validity MevSendBundleValidity) BundleOption
- type BundleStats
- type EthCallBundleParams
- type EthCancelBundleParams
- type EthCancelPrivateTransactionParams
- type EthSendBundleParams
- type EthSendPrivateRawTransactionParams
- type EthSendPrivateTransactionParams
- type FlashbotsGetFeeRefundTotalsByRecipientParams
- type FlashbotsGetFeeRefundsByBlockParams
- type FlashbotsGetFeeRefundsByBundleParams
- type FlashbotsGetFeeRefundsByRecipientParams
- type FlashbotsGetMevRefundTotalByRecipientParams
- type FlashbotsGetMevRefundTotalBySenderParams
- type FlashbotsSetFeeRefundRecipientParams
- type IFlashbot
- type JsonRpcResponse
- type LogEntry
- type MevBody
- type MevInclusion
- type MevPrivacy
- type MevSendBundleMetadata
- type MevSendBundleParams
- type MevSendBundlePrivacy
- type MevSendBundleRefund
- type MevSendBundleRefundConfig
- type MevSendBundleValidity
- type MevSimArgs
- type MevSimResponse
- type Option
- type SimulateResponse
- type TxLogResult
- type UserStats
Constants ¶
const ( MainnetChainID = 1 SepoliaChainID = 11155111 MainnetRelayURL = "https://relay.flashbots.net" SepoliaRelayURL = "https://relay-sepolia.flashbots.net" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastResponse ¶
type BroadcastResult ¶
type BuildernetGetDelayedRefundTotalsByRecipientParams ¶
type BuildernetGetDelayedRefundTotalsByRecipientParams struct {
Recipient string `json:"recipient"`
BlockRangeFrom *string `json:"blockRangeFrom,omitempty"`
BlockRangeTo *string `json:"blockRangeTo,omitempty"`
}
BuildernetGetDelayedRefundTotalsByRecipientParams represents the parameters for buildernet_getDelayedRefundTotalsByRecipient. recipient: Address to query for delayed refunds blockRangeFrom: (Optional) Hex-encoded block number for start of range (inclusive) blockRangeTo: (Optional) Hex-encoded block number for end of range (inclusive)
type BuildernetGetDelayedRefundsParams ¶
type BuildernetGetDelayedRefundsParams struct {
Recipient string `json:"recipient"`
BlockRangeFrom *string `json:"blockRangeFrom,omitempty"`
BlockRangeTo *string `json:"blockRangeTo,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Hash *string `json:"hash,omitempty"`
}
BuildernetGetDelayedRefundsParams represents the parameters for buildernet_getDelayedRefunds. recipient: Address that receives delayed refunds blockRangeFrom: (Optional) Hex-encoded block number for start of range (inclusive) blockRangeTo: (Optional) Hex-encoded block number for end of range (inclusive) cursor: (Optional) Cursor to continue from hash: (Optional) Bundle hash; if provided, must also set both blockRangeFrom and blockRangeTo
type Bundle ¶
type Bundle struct {
// Transactions is a list of transactions to be included in the bundle.
Transactions []*types.Transaction
// CanRevert is a list of booleans indicating whether each transaction can revert. len(CanRevert) == len(Transactions).
CanRevert []bool
// ReplacementUUID is the UUID of the bundle to replace.
ReplacementUUID string
// Builders is a list of builders to send the bundle to.
Builders []string
// MinTimestamp is the minimum timestamp for which the bundle is valid.
MinTimestamp int64
}
Bundle is a struct that represents a bundle of transactions.
type BundleOption ¶
type BundleOption func(*mevSimBundleParams) error
BundleOption is a function that can be used to configure the bundle.
func WithExpirationBlock ¶
func WithExpirationBlock(block uint64) BundleOption
func WithExpirationDurationInBlocks ¶
func WithExpirationDurationInBlocks(duration uint64) BundleOption
func WithMetadata ¶
func WithMetadata(metadata MevSendBundleMetadata) BundleOption
WithMetadata sets the metadata for the bundle.
func WithPrivacy ¶
func WithPrivacy(privacy MevSendBundlePrivacy) BundleOption
WithPrivacy sets the privacy configuration for the bundle.
func WithValidity ¶
func WithValidity(validity MevSendBundleValidity) BundleOption
WithValidity sets the validity configuration for the bundle.
type BundleStats ¶
type EthCallBundleParams ¶
type EthCallBundleParams struct {
Txs []string `json:"txs"`
BlockNumber string `json:"blockNumber"`
StateBlockNumber string `json:"stateBlockNumber"`
Timestamp *int64 `json:"timestamp,omitempty"`
}
EthCallBundleParams represents the parameters for eth_callBundle. txs: Array of signed transactions to execute in an atomic bundle blockNumber: Hex-encoded block number for which this bundle is valid stateBlockNumber: Hex-encoded number or block tag (e.g., "latest") for which state to base simulation on timestamp: (Optional) Timestamp to use for bundle simulation, in seconds since unix epoch
type EthCancelBundleParams ¶
type EthCancelBundleParams struct {
ReplacementUuid string `json:"replacementUuid"`
}
EthCancelBundleParams represents the parameters for eth_cancelBundle. replacementUuid: UUID of the bundle to cancel
type EthCancelPrivateTransactionParams ¶
type EthCancelPrivateTransactionParams struct {
TxHash string `json:"txHash"`
}
EthCancelPrivateTransactionParams represents the parameters for eth_cancelPrivateTransaction.
type EthSendBundleParams ¶
type EthSendBundleParams struct {
Txs []string `json:"txs"`
BlockNumber string `json:"blockNumber"`
MinTimestamp *int64 `json:"minTimestamp,omitempty"`
MaxTimestamp *int64 `json:"maxTimestamp,omitempty"`
RevertingTxHashes []string `json:"revertingTxHashes,omitempty"`
ReplacementUuid *string `json:"replacementUuid,omitempty"`
Builders []string `json:"builders,omitempty"`
}
EthSendBundleParams represents the parameters for eth_sendBundle. txs: Array of signed transactions to execute in an atomic bundle blockNumber: Hex-encoded block number for which this bundle is valid minTimestamp: (Optional) Minimum timestamp for which this bundle is valid, in seconds since unix epoch maxTimestamp: (Optional) Maximum timestamp for which this bundle is valid, in seconds since unix epoch revertingTxHashes: (Optional) Array of tx hashes that are allowed to revert replacementUuid: (Optional) UUID that can be used to cancel/replace this bundle builders: (Optional) Array of registered block builder names to share the bundle with
type EthSendPrivateRawTransactionParams ¶
type EthSendPrivateRawTransactionParams struct {
Tx string `json:"tx"`
MaxBlockNumber *string `json:"maxBlockNumber,omitempty"`
}
EthSendPrivateRawTransactionParams represents the parameters for eth_sendPrivateRawTransaction.
type EthSendPrivateTransactionParams ¶
type EthSendPrivateTransactionParams struct {
Tx string `json:"tx"`
MaxBlockNumber *string `json:"maxBlockNumber,omitempty"`
}
EthSendPrivateTransactionParams represents the parameters for eth_sendPrivateTransaction.
type FlashbotsGetFeeRefundTotalsByRecipientParams ¶
type FlashbotsGetFeeRefundTotalsByRecipientParams struct {
Recipient string `json:"recipient"`
}
FlashbotsGetFeeRefundTotalsByRecipientParams represents the parameters for flashbots_getFeeRefundTotalsByRecipient.
type FlashbotsGetFeeRefundsByBlockParams ¶
type FlashbotsGetFeeRefundsByBlockParams struct {
BlockNumber string `json:"blockNumber"`
}
FlashbotsGetFeeRefundsByBlockParams represents the parameters for flashbots_getFeeRefundsByBlock.
type FlashbotsGetFeeRefundsByBundleParams ¶
type FlashbotsGetFeeRefundsByBundleParams struct {
BundleHash string `json:"bundleHash"`
}
FlashbotsGetFeeRefundsByBundleParams represents the parameters for flashbots_getFeeRefundsByBundle.
type FlashbotsGetFeeRefundsByRecipientParams ¶
type FlashbotsGetFeeRefundsByRecipientParams struct {
Recipient string `json:"recipient"`
}
FlashbotsGetFeeRefundsByRecipientParams represents the parameters for flashbots_getFeeRefundsByRecipient.
type FlashbotsGetMevRefundTotalByRecipientParams ¶
type FlashbotsGetMevRefundTotalByRecipientParams struct {
Recipient string `json:"recipient"`
}
FlashbotsGetMevRefundTotalByRecipientParams represents the parameters for flashbots_getMevRefundTotalByRecipient. Returns the total amount of MEV refunds paid to a recipient address. Does not require authentication.
type FlashbotsGetMevRefundTotalBySenderParams ¶
type FlashbotsGetMevRefundTotalBySenderParams struct {
Sender string `json:"sender"`
}
FlashbotsGetMevRefundTotalBySenderParams represents the parameters for flashbots_getMevRefundTotalBySender. Returns the total amount of MEV refunds generated on transactions/bundles from a sender address. The sender is tx.origin for individual transactions or bundles of size 1, or the Flashbots signer for bundles of size > 1. Does not require authentication.
type FlashbotsSetFeeRefundRecipientParams ¶
type FlashbotsSetFeeRefundRecipientParams struct {
Recipient string `json:"recipient"`
}
FlashbotsSetFeeRefundRecipientParams represents the parameters for flashbots_setFeeRefundRecipient.
type IFlashbot ¶
type IFlashbot interface {
// Simulate runs the bundle against the Flashbots Relay to check for reverts.
// This should ALWAYS be called before Broadcast.
// blockNumber: The target block you want to land in.
// stateBlock: The block state to simulate on (usually target - 1).
Simulate(ctx context.Context, bundle *Bundle, targetBlock uint64, opts ...BundleOption) (*SimulateResponse, error)
// Broadcast sends the bundle to the configured list of builders (Titan, Beaver, Flashbots, etc.).
// It returns the list of builders that accepted the request.
Broadcast(ctx context.Context, bundle *Bundle, targetBlock uint64, opts ...BundleOption) (*BroadcastResponse, error)
// SendPrivateTransaction sends a single transaction directly to builders (eth_sendPrivateTransaction).
// Useful for simple transfers where you don't need a full bundle but want frontrunning protection.
// expDurationBlocks: The expected duration of the transaction in blocks. max 25 blocks. default 25 blocks.
SendPrivateTransaction(ctx context.Context, signedTxHex string, expDurationBlocks uint64) error
// GetGasPrice returns the suggested gas price.
// For EIP-1559 chains, this should return the BaseFee + PriorityFee.
// You can implement this to return a "fast" price for aggressive inclusion.
GetGasPrice(ctx context.Context) (gasPrice *big.Int, tip *big.Int, err error)
// EstimateGasBundle calculates the gas units required for the entire bundle.
// This is useful for calculating exactly how much "sponsorship" ETH to send the user.
EstimateGasBundle(ctx context.Context, bundle *Bundle) (uint64, error)
// GetUserStats checks your signing key's reputation on the relay.
GetUserStats(ctx context.Context, blockNumber *big.Int) (*UserStats, error)
}
IFlashBot defines the standard behavior for a MEV/Flashbots client. It unifies Simulation (Relay) and Broadcasting (Builders).
type JsonRpcResponse ¶
type JsonRpcResponse struct {
Id int `json:"id"`
Result *callBundleResp `json:"result,omitempty"`
Error *rpcError `json:"error,omitempty"`
}
type MevInclusion ¶
type MevPrivacy ¶
type MevPrivacy struct {
Hints []string `json:"hints,omitempty"` // e.g. ["calldata", "logs"]
}
type MevSendBundleMetadata ¶
type MevSendBundleMetadata struct {
OriginID *string `json:"originId,omitempty"`
}
MevSendBundleMetadata represents metadata for mev_sendBundle.
type MevSendBundleParams ¶
type MevSendBundleParams struct {
Version string `json:"version"` // "v0.1"
Inclusion mevSendBundleInclusion `json:"inclusion"`
Body []mevSendBundleBodyItem `json:"body"`
Validity *MevSendBundleValidity `json:"validity,omitempty"`
Privacy *MevSendBundlePrivacy `json:"privacy,omitempty"`
Metadata *MevSendBundleMetadata `json:"metadata,omitempty"`
}
MevSendBundleParams represents the parameters for mev_sendBundle. Uses a new bundle format to send bundles to MEV-Share.
type MevSendBundlePrivacy ¶
type MevSendBundlePrivacy struct {
Hints []string `json:"hints,omitempty"` // "calldata", "contract_address", "logs", "function_selector", "hash", "tx_hash", "full"
Builders []string `json:"builders,omitempty"`
}
MevSendBundlePrivacy represents privacy configuration for mev_sendBundle.
type MevSendBundleRefund ¶
MevSendBundleRefund represents a refund configuration in validity.
type MevSendBundleRefundConfig ¶
type MevSendBundleRefundConfig struct {
Address string `json:"address"`
Percent float64 `json:"percent"`
}
MevSendBundleRefundConfig represents a refund configuration by address.
type MevSendBundleValidity ¶
type MevSendBundleValidity struct {
Refund []MevSendBundleRefund `json:"refund,omitempty"`
RefundConfig []MevSendBundleRefundConfig `json:"refundConfig,omitempty"`
}
MevSendBundleValidity represents validity configuration for mev_sendBundle.
type MevSimArgs ¶
type MevSimArgs struct {
Version string `json:"version"` // Usually "v0.1"
Inclusion MevInclusion `json:"inclusion"`
Body []MevBody `json:"body"`
Privacy *MevPrivacy `json:"privacy,omitempty"` // Optional
}
MevSimArgs is the wrapper for params
type MevSimResponse ¶
type MevSimResponse struct {
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 []TxLogResult `json:"logs,omitempty"` // <--- The best part
}
MevSimResponse captures the detailed output
type Option ¶
type Option func(*flashbot) error
func WithBuilders ¶
func WithChainID ¶
func WithRelayURL ¶
type SimulateResponse ¶
type SimulateResponse = MevSimResponse
type TxLogResult ¶
type TxLogResult struct {
TxLogs []LogEntry `json:"txLogs,omitempty"`
}