Documentation ¶
Overview ¶
Package relayer is the entry point for the STIP Relayer
Index ¶
- Variables
- type CustomTime
- type Metadata
- type QueryResult
- type Result
- type Row
- type STIPRelayer
- func (s *STIPRelayer) CalculateTransferAmount(ctx context.Context, transaction *db.STIPTransactions) (*big.Int, error)
- func (s *STIPRelayer) ExecuteDuneQuery(parentCtx context.Context) (executionID string, err error)
- func (s *STIPRelayer) GetExecutionResults(parentCtx context.Context, executionID string) (_ *QueryResult, err error)
- func (s *STIPRelayer) ProcessExecutionResults(parentCtx context.Context) (err error)
- func (s *STIPRelayer) QueryRebateAndUpdate(ctx context.Context) error
- func (s *STIPRelayer) RelayAndRebateTransactions(ctx context.Context) error
- func (s *STIPRelayer) RequestAndStoreResults(ctx context.Context) error
- func (s *STIPRelayer) Run(ctx context.Context) error
- func (s *STIPRelayer) StartSubmitter(ctx context.Context) error
- func (s *STIPRelayer) StoreResultsInDatabase(ctx context.Context, rows []Row, executionID string) error
- func (s *STIPRelayer) SubmitAndRebateTransaction(ctx context.Context, transaction *db.STIPTransactions) error
Constants ¶
This section is empty.
Variables ¶
var DuneAPIKey = os.Getenv("DUNE_API_KEY")
DuneAPIKey is the API key for Dune, fetched from the environment variables.
Functions ¶
This section is empty.
Types ¶
type CustomTime ¶
CustomTime is a custom time type for handling specific time format in JSON unmarshalling.
func (*CustomTime) UnmarshalJSON ¶
func (ct *CustomTime) UnmarshalJSON(b []byte) error
UnmarshalJSON overrides the default JSON unmarshaling for CustomTime to handle specific time format.
type Metadata ¶
type Metadata struct { ColumnNames []string `json:"column_names"` ResultSetBytes int `json:"result_set_bytes"` TotalRowCount int `json:"total_row_count"` DatapointCount int `json:"datapoint_count"` PendingTimeMillis int `json:"pending_time_millis"` ExecutionTimeMillis int `json:"execution_time_millis"` }
Metadata represents the metadata of a query execution result.
type QueryResult ¶
type QueryResult struct { ExecutionID string `json:"execution_id"` QueryID int `json:"query_id"` State string `json:"state"` SubmittedAt time.Time `json:"submitted_at"` ExpiresAt time.Time `json:"expires_at"` ExecutionStartedAt time.Time `json:"execution_started_at"` ExecutionEndedAt time.Time `json:"execution_ended_at"` Result Result `json:"result"` }
QueryResult represents the result of a Dune query.
type Row ¶
type Row struct { Address string `json:"address"` Amount float64 `json:"amount"` AmountUsd float64 `json:"amount_usd"` ArbPrice float64 `json:"arb_price"` BlockTime CustomTime `json:"block_time"` Direction string `json:"direction"` Hash string `json:"hash"` Module string `json:"module"` Token string `json:"token"` TokenPrice float64 `json:"token_price"` }
Row represents a single row of the result of a query execution.
type STIPRelayer ¶
type STIPRelayer struct {
// contains filtered or unexported fields
}
STIPRelayer is the main struct for the STIP relayer service.
func NewSTIPRelayer ¶
func NewSTIPRelayer(ctx context.Context, cfg stipconfig.Config, handler metrics.Handler, omniRPCClient omniClient.RPCClient, store db.STIPDB, ) (*STIPRelayer, error)
NewSTIPRelayer creates a new STIPRelayer with the provided context and configuration.
func (*STIPRelayer) CalculateTransferAmount ¶
func (s *STIPRelayer) CalculateTransferAmount(ctx context.Context, transaction *db.STIPTransactions) (*big.Int, error)
CalculateTransferAmount determines the amount to transfer based on the transaction.
func (*STIPRelayer) ExecuteDuneQuery ¶
func (s *STIPRelayer) ExecuteDuneQuery(parentCtx context.Context) (executionID string, err error)
ExecuteDuneQuery executes a predefined query on the Dune API and returns the http response.
func (*STIPRelayer) GetExecutionResults ¶
func (s *STIPRelayer) GetExecutionResults(parentCtx context.Context, executionID string) (_ *QueryResult, err error)
GetExecutionResults fetches the results of a Dune query execution using the provided execution ID.
func (*STIPRelayer) ProcessExecutionResults ¶
func (s *STIPRelayer) ProcessExecutionResults(parentCtx context.Context) (err error)
ProcessExecutionResults encapsulates the logic for requesting and storing execution results.
func (*STIPRelayer) QueryRebateAndUpdate ¶
func (s *STIPRelayer) QueryRebateAndUpdate(ctx context.Context) error
QueryRebateAndUpdate handles the querying for new, non-relayed/rebated results, rebates/relays them, and updates the result row.
func (*STIPRelayer) RelayAndRebateTransactions ¶
func (s *STIPRelayer) RelayAndRebateTransactions(ctx context.Context) error
RelayAndRebateTransactions encapsulates the logic for querying, rebating/relaying, and updating results.
func (*STIPRelayer) RequestAndStoreResults ¶
func (s *STIPRelayer) RequestAndStoreResults(ctx context.Context) error
RequestAndStoreResults handles the continuous request of new execution results and storing them in the database.
func (*STIPRelayer) Run ¶
func (s *STIPRelayer) Run(ctx context.Context) error
Run starts the STIPRelayer service by initiating various goroutines.
func (*STIPRelayer) StartSubmitter ¶
func (s *STIPRelayer) StartSubmitter(ctx context.Context) error
StartSubmitter handles the initialization of the submitter.
func (*STIPRelayer) StoreResultsInDatabase ¶
func (s *STIPRelayer) StoreResultsInDatabase(ctx context.Context, rows []Row, executionID string) error
StoreResultsInDatabase handles the storage of results in the database.
func (*STIPRelayer) SubmitAndRebateTransaction ¶
func (s *STIPRelayer) SubmitAndRebateTransaction(ctx context.Context, transaction *db.STIPTransactions) error
SubmitAndRebateTransaction handles the relaying and rebating of a single transaction. nolint: cyclop