Documentation ¶
Index ¶
- Variables
- func EthToWei(n float64) *big.Int
- func IsValidTxHash(tx string) bool
- func IsZeroAddress(address ethereum.Address) bool
- func NewEthereumClient(ethereumNodeURL string) (*ethclient.Client, error)
- func NodeTypeStrings() []string
- type BlockTimeResolver
- type BlockTimeResolverInterface
- type ChainNode
- type MockBlockTimeResolve
- type NodePool
- func (n *NodePool) FilterLogs(chain cm.Chain, query ether.FilterQuery) ([]types.Log, error)
- func (n *NodePool) GetBlockNumber(chain cm.Chain) (uint64, error)
- func (n *NodePool) GetBlockTimeStamp(chain cm.Chain, timeout time.Duration, blockNumber uint64) (*types.Header, error)
- func (n *NodePool) GetDecimal(chain cm.Chain, address common.Address, timeout time.Duration) (uint8, error)
- func (n *NodePool) GetTxData(chain cm.Chain, txHash common.Hash, timeout time.Duration) (*types.Receipt, common.Address, error)
- type NodeType
- func (i NodeType) IsANodeType() bool
- func (i NodeType) MarshalJSON() ([]byte, error)
- func (i NodeType) MarshalText() ([]byte, error)
- func (i *NodeType) Scan(value interface{}) error
- func (i NodeType) String() string
- func (i *NodeType) UnmarshalJSON(data []byte) error
- func (i *NodeType) UnmarshalText(text []byte) error
- func (i NodeType) Value() (driver.Value, error)
- type TokenAmountFormatter
- type TokenAmountFormatterInterface
Constants ¶
This section is empty.
Variables ¶
var ( BaseWEthAddr = strings.ToLower("0x4200000000000000000000000000000000000006") BaseUsdcAddr = strings.ToLower("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913") BaseUsdAddr = strings.ToLower("0xB79DD08EA68A908A97220C76d19A6aA9cBDE4376") BaseDaiAddr = strings.ToLower("0x50c5725949a6f0c72e6c4a641f24049a917db0cb") )
var ( // ETHAddr is ethereum address ETHAddr = strings.ToLower("0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") // WETHAddr is wrapped ETH address WETHAddr = strings.ToLower("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") // USDTAddr is usdt address USDTAddr = strings.ToLower("0xdac17f958d2ee523a2206206994597c13d831ec7") // USDCAddr is usdc address USDCAddr = strings.ToLower("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") // DAIAddr is dai address DAIAddr = strings.ToLower("0x6b175474e89094c44da98b954eedeac495271d0f") // FraxAddr is frax address FraxAddr = strings.ToLower("0x853d955acef822db058eb8505911ed77f175b99e") // Wbtc is frax address WBTCAddr = strings.ToLower("0x2260fac5e5542a773aa44fbcfedf7c193bc2c599") )
Functions ¶
func IsZeroAddress ¶
IsZeroAddress return if address is zero
func NewEthereumClient ¶
NewEthereumClientFromFlag returns Ethereum client from flag variable, or error if occurs
func NodeTypeStrings ¶
func NodeTypeStrings() []string
NodeTypeStrings returns a slice of all String values of the enum
Types ¶
type BlockTimeResolver ¶
type BlockTimeResolver struct {
// contains filtered or unexported fields
}
BlockTimeResolver is a helper to get transaction timestamp from block number. It has a cache for one block.
func NewBlockTimeResolver ¶
func NewBlockTimeResolver(log *zap.SugaredLogger, nodePool *NodePool, timeout time.Duration) (*BlockTimeResolver, error)
NewBlockTimeResolver returns BlockTimeResolver instance given a ethereum client.
type BlockTimeResolverInterface ¶
type BlockTimeResolverInterface interface { Sync(chain common.Chain, fromBlock, toBlock uint64) error Resolve(chain common.Chain, blockNumber uint64) (time.Time, error) }
BlockTimeResolverInterface define the functionality
type MockBlockTimeResolve ¶
type MockBlockTimeResolve struct {
// contains filtered or unexported fields
}
MockBlockTimeResolve is the mock implementation of blockTimeResolver for testing
func NewMockBlockTimeResolve ¶
func NewMockBlockTimeResolve(ts time.Time) *MockBlockTimeResolve
NewMockBlockTimeResolve creates new instance of MockBlockTimeResolve
type NodePool ¶
type NodePool struct {
// contains filtered or unexported fields
}
func NewNodePool ¶
func (*NodePool) FilterLogs ¶
func (*NodePool) GetBlockTimeStamp ¶
func (*NodePool) GetDecimal ¶
type NodeType ¶
type NodeType uint64
enumer -type=NodeType -linecomment -json=true -text=true -sql=true
func NodeTypeString ¶
NodeTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func NodeTypeValues ¶
func NodeTypeValues() []NodeType
NodeTypeValues returns all values of the enum
func (NodeType) IsANodeType ¶
IsANodeType returns "true" if the value is listed in the enum definition. "false" otherwise
func (NodeType) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for NodeType
func (NodeType) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for NodeType
func (*NodeType) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for NodeType
func (*NodeType) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for NodeType
type TokenAmountFormatter ¶
type TokenAmountFormatter struct {
// contains filtered or unexported fields
}
TokenAmountFormatter is a helper to convert token amount from/to wei
func NewTokenAmountFormatter ¶
func NewTokenAmountFormatter(log *zap.SugaredLogger, nodePool *NodePool) (*TokenAmountFormatter, error)
NewTokenAmountFormatter returns a new TokenAmountFormatter instance.
func (*TokenAmountFormatter) FromWei ¶
func (f *TokenAmountFormatter) FromWei(chain cm.Chain, address common.Address, amount *big.Int) (float64, error)
FromWei formats the given amount in wei to human friendly number with token decimals from contract.
func (*TokenAmountFormatter) GetDecimals ¶
GetDecimals return decimals of a token