Documentation ¶
Overview ¶
Package bclient provides a wrapper around go-ethereum's ethclient package
Index ¶
- Variables
- type BClient
- func (bc *BClient) Blockchain() utils.Blockchain
- func (bc *BClient) ChainID() (*big.Int, error)
- func (bc *BClient) Close()
- func (bc *BClient) Context() context.Context
- func (bc *BClient) CurrentBlock() (uint64, error)
- func (bc *BClient) EncodeTx(hash string) (string, error)
- func (bc *BClient) EthClient() (*ethclient.Client, error)
- func (bc *BClient) EthDaiPrice() (*big.Int, error)
- func (bc *BClient) Sushiswap() *sushiswap.Client
- func (bc *BClient) Uniswap() *uniswap.Client
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotEthClient is an error return when attempting to do type conversions against the // blockchain interface to an ethclient, when the underlying blockchain interface is not // an ethclient type. Usually will be encountered when using a simulated backend ErrNotEthClient = errors.New("underlying blockchain provider is not of type ethclient.Client") // ErrNotSimulatedBackend is an error returned when attempting to do type conversions against the // blockchain interface to a simulated backend, when the underlying blockchain interface is not // a simulated backend type. Usually will be encountered when using an ethclient backend ErrNotSimulatedBackend = errors.New("underlying blockchain provider is not of type simulated backend") )
var ( // WETHTokenAddress is the address of the WETH token contract WETHTokenAddress = common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") // DAITokenAddress is the address of the MCD (Multi Collateral DAI) contract DAITokenAddress = common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f") )
token addresses
Functions ¶
This section is empty.
Types ¶
type BClient ¶
type BClient struct {
// contains filtered or unexported fields
}
BClient wraps ethclient and provides helper functions for commonly used functionality
func NewClient ¶
New returns a new bclient implementation without any authentication as well as wrappers around the uniswap and sushiswap clients. All underlying types are exposed in addition to helper functions
func (*BClient) Blockchain ¶
func (bc *BClient) Blockchain() utils.Blockchain
Blockchain returns the underlying blockchain interface
func (*BClient) ChainID ¶
ChainID performs a best effort at determining the chainid we do this by first attempting to retrieve the id from a simulated backend, and if that fails get the chain id from an ethclient
func (*BClient) CurrentBlock ¶
CurrentBlock returns the current block known by the ethereum client
func (*BClient) EncodeTx ¶
EncodeTx is used to marshal a transaction and hex encode it suitable for encoding transctions and storing them into a database
func (*BClient) EthClient ¶
EthClient attempts to conver the Blockchain interface to an ethclient type returning an error if unable to type convert the interface. This likely indicates that a simulated backend is being used
func (*BClient) EthDaiPrice ¶
EthDaiPrice returns the price of ETH in terms of DAI