tradeExecution

package
v0.0.0-...-bde3006 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTokenBalance

func CheckTokenBalance(tokenAddress, address common.Address, client *ethclient.Client) (error, *big.Int)

Checks token balance of a given address

func ConvertETHtoWETH

func ConvertETHtoWETH(zk *Zk,
	client *ethclient.Client,
	chainID *big.Int,
	instance *contracts.FlashbotsTrader,
	WETHAddress string,
	ETHAmount_wei,
	gasPrice *big.Int) (*types.Transaction, error)

Converts ETHAmount_wei into WETH Note: Assumes contract already has ETH

func GetOurRawTx

func GetOurRawTx(zk *Zk,
	chainID *big.Int,
	client *ethclient.Client,
	nonce uint64,
	token0 common.Address,
	instance *contracts.FlashbotsTrader,
	gasPrice *big.Int,
	inputToken,
	poolAddress common.Address,
	minerAmount,
	inputTokenAmount,
	outputTokenAmount,
	blockNumberToExecute *big.Int) (*types.Transaction, string, error)

Get our txHash and raw signed transaction

func GetPairAddress

func GetPairAddress(contractAddress, token, otherToken string) (common.Address, common.Address, error)

Get the address of a UniswapV2 / SushiswapV2 pair given two contract addresses The first string returned is token0

func GetRawTx

func GetRawTx(hash string) string

Given a user's tx Hash, we use an RPC method to get its raw signed data

func Kill

func Kill(zk *Zk,
	client *ethclient.Client,
	chainID *big.Int,
	instance *contracts.FlashbotsTrader,
	gasPrice *big.Int) (*types.Transaction, error)

Selfdestructs instance and sends any ETH to our EOA

func SendFlashbotsBundle

func SendFlashbotsBundle(zk *Zk,
	client *ethclient.Client,
	flashbotsRelay string,
	bundle []string,
	blockNumberToExecute *big.Int) (string, error)

Sends bundle to Flashbots relay, targetting a specific blockNumber to execute

func SetContractTrader

func SetContractTrader(client *ethclient.Client, _address string) *contracts.FlashbotsTrader

Loads instance of FlashbotsTrader contract at its deployed address

Types

type FlashbotsTradeReturn

type FlashbotsTradeReturn struct {
	Executed      bool
	Txs           map[*big.Int][2]common.Hash
	BlockDeadline *big.Int
}

func ExecuteDEXBuyAndSell

func ExecuteDEXBuyAndSell(zk *Zk,
	chainID *big.Int,
	client *ethclient.Client,
	instance *contracts.FlashbotsTrader,
	flashbotsRelay string,
	WETHAddress,
	tokenAddress,
	poolAddress,
	token0 common.Address,
	WETHAmountBuy_wei,
	TokenAmountBuy,
	WETHAmountSell_wei,
	gasPrice,
	minerAmount *big.Int,
	nBundles uint64) (FlashbotsTradeReturn, error)

Simple example of submitting a WETH -> Token Buy, followed by a Token -> WETH sell. Works for both Flashbots and mempool, as dictated by isMempool bool.

type Zk

type Zk struct {
	D           *ecdsa.PrivateKey
	FromAddress common.Address
}

EOA struct

func Init

func Init(walletAddressIdx int) *Zk

func (*Zk) SetWalletFromMnemonic

func (zk *Zk) SetWalletFromMnemonic(walletAddressIdx int)

Setup wallet struct from mnemonic input, picking one of its EOA addresses via walletAddressIdx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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