Documentation ¶
Overview ¶
Package consumer provides a consumer for the database. It deals with querying, parsing, and storing logs.
Index ¶
- Variables
- func BoolToUint8(input *bool) *uint8
- func GetAmountUSD(amount *big.Int, decimals uint8, price *float64) *float64
- func GetDefiLlamaData(ctx context.Context, timestamp int, coinGeckoID *string) (*float64, *string)
- func GetTokenMetadataWithTokenID(ctx context.Context, timestamp int, tokenID *string) (*float64, *string)
- func GetTokenMetadataWithTokenSymbol(ctx context.Context, timestamp int, tokenSymbol *string) (*float64, *string)
- func OpenYaml(path string) (map[string]string, error)
- func ToNullString(str *string) sql.NullString
- type BridgeConfigFetcher
- func (b *BridgeConfigFetcher) GetToken(ctx context.Context, chainID uint32, tokenID *string, blockNumber uint32) (token *bridgeconfig.BridgeConfigV3Token, err error)
- func (b *BridgeConfigFetcher) GetTokenID(ctx context.Context, chainID uint32, tokenAddress common.Address) (tokenID *string, err error)
- type BridgeParser
- type Fetcher
- func (f Fetcher) FetchLastBlock(ctx context.Context, chainID uint32) (uint64, error)
- func (f Fetcher) FetchLastIndexed(ctx context.Context, chainID uint32, contractAddress string) (uint64, error)
- func (f Fetcher) FetchLogsInRange(ctx context.Context, chainID uint32, startBlock, endBlock uint64, ...) ([]ethTypes.Log, error)
- func (f Fetcher) FetchTxSender(ctx context.Context, chainID uint32, txHash string) (string, error)
- func (f Fetcher) TimeToBlockNumber(ctx context.Context, chainID uint32, startHeight, targetTime uint64) (uint64, error)
- type Parser
- type SwapFetcher
- type SwapParser
Constants ¶
This section is empty.
Variables ¶
var ErrTokenDoesNotExist = errors.New("token id does not exist")
ErrTokenDoesNotExist indicates the queried for token does not exist.
Functions ¶
func BoolToUint8 ¶ added in v0.0.9
BoolToUint8 is a helper function to handle bool to uint8 conversion for clickhouse.
func GetAmountUSD ¶ added in v0.0.9
GetAmountUSD computes the USD value of a token amount.
func GetDefiLlamaData ¶ added in v0.0.9
GetDefiLlamaData does a get request to defi llama for the symbol and price for a token.
func GetTokenMetadataWithTokenID ¶ added in v0.0.9
func GetTokenMetadataWithTokenID(ctx context.Context, timestamp int, tokenID *string) (*float64, *string)
GetTokenMetadataWithTokenID gets the token metadata (symbol, price).
func GetTokenMetadataWithTokenSymbol ¶ added in v0.0.9
func GetTokenMetadataWithTokenSymbol(ctx context.Context, timestamp int, tokenSymbol *string) (*float64, *string)
GetTokenMetadataWithTokenSymbol gets the token metadata (symbol, price).
func ToNullString ¶ added in v0.0.9
func ToNullString(str *string) sql.NullString
ToNullString is a helper function to convert values to null string.
Types ¶
type BridgeConfigFetcher ¶
type BridgeConfigFetcher struct { // contains filtered or unexported fields } // TODO switch bridge config based on block number
BridgeConfigFetcher is the fetcher for the bridge config contract.
func NewBridgeConfigFetcher ¶
func NewBridgeConfigFetcher(bridgeConfigAddress common.Address, bridgeConfigRef *bridgeconfig.BridgeConfigRef) (*BridgeConfigFetcher, error)
NewBridgeConfigFetcher creates a new config fetcher. Backend must be an archive backend.
func (*BridgeConfigFetcher) GetToken ¶
func (b *BridgeConfigFetcher) GetToken(ctx context.Context, chainID uint32, tokenID *string, blockNumber uint32) (token *bridgeconfig.BridgeConfigV3Token, err error)
GetToken gets the token from the bridge config contract. Requires an archived note.
func (*BridgeConfigFetcher) GetTokenID ¶
func (b *BridgeConfigFetcher) GetTokenID(ctx context.Context, chainID uint32, tokenAddress common.Address) (tokenID *string, err error)
GetTokenID gets the token id from the bridge config contract.
type BridgeParser ¶
type BridgeParser struct { // Filterer is the bridge Filterer we use to parse events Filterer *bridge.SynapseBridgeFilterer // contains filtered or unexported fields }
BridgeParser parses events from the bridge contract.
func NewBridgeParser ¶
func NewBridgeParser(consumerDB db.ConsumerDB, bridgeAddress common.Address, bridgeConfigFetcher BridgeConfigFetcher, consumerFetcher *Fetcher) (*BridgeParser, error)
NewBridgeParser creates a new parser for a given bridge.
func (*BridgeParser) EventType ¶
func (p *BridgeParser) EventType(log ethTypes.Log) (_ bridgeTypes.EventType, ok bool)
EventType returns the event type of a bridge log.
func (*BridgeParser) ParseAndStore ¶
ParseAndStore parses the bridge logs and stores them in the database.
nolint:gocognit,cyclop,dupl
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher is the fetcher for the events. It uses GQL.
func NewFetcher ¶
NewFetcher creates a new fetcher.
func (Fetcher) FetchLastBlock ¶ added in v0.0.11
FetchLastBlock fetches the last block that Scribe has stored.
func (Fetcher) FetchLastIndexed ¶ added in v0.0.11
func (f Fetcher) FetchLastIndexed(ctx context.Context, chainID uint32, contractAddress string) (uint64, error)
FetchLastIndexed fetches the last indexed block per contract.
func (Fetcher) FetchLogsInRange ¶
func (f Fetcher) FetchLogsInRange(ctx context.Context, chainID uint32, startBlock, endBlock uint64, contractAddress common.Address) ([]ethTypes.Log, error)
FetchLogsInRange fetches logs in a range with the GQL client.
func (Fetcher) FetchTxSender ¶ added in v0.0.9
FetchTxSender fetches the sender of a transaction.
type Parser ¶
type Parser interface { // ParseAndStore parses the logs and stores them in the database. ParseAndStore(ctx context.Context, log ethTypes.Log, chainID uint32) error }
Parser parses events and stores them.
type SwapFetcher ¶ added in v0.0.9
type SwapFetcher struct {
// contains filtered or unexported fields
}
SwapFetcher is the fetcher for token data from the swap contract.
func NewSwapFetcher ¶ added in v0.0.9
func NewSwapFetcher(swapAddress common.Address, backend bind.ContractBackend) (*SwapFetcher, error)
NewSwapFetcher creates a new swap fetcher. Backend must be an archive backend.
func (*SwapFetcher) GetTokenMetaData ¶ added in v0.0.9
GetTokenMetaData gets the token from the erc20 token contract given a swap contract token id.
type SwapParser ¶
type SwapParser struct { // Filterer is the swap Filterer we use to parse events Filterer *swap.SwapFlashLoanFilterer // contains filtered or unexported fields }
SwapParser parses events from the swap contract.
func NewSwapParser ¶
func NewSwapParser(consumerDB db.ConsumerDB, swapAddress common.Address, swapFetcher SwapFetcher, consumerFetcher *Fetcher) (*SwapParser, error)
NewSwapParser creates a new parser for a given bridge.
func (*SwapParser) ParseAndStore ¶
ParseAndStore parses and stores the swap logs.
Directories ¶
Path | Synopsis |
---|---|
Package backfill provides a command to backfill the consumer database.
|
Package backfill provides a command to backfill the consumer database. |
Package client provides a GraphQL client for consuming logs.
|
Package client provides a GraphQL client for consuming logs. |
contrib
Package main generates a GQL client.
|
Package main generates a GQL client. |
Package node contains the node for the explorer service.
|
Package node contains the node for the explorer service. |