relconfig

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package relconfig contains the config yaml object for the relayer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	// Bridge is the bridge confirmation count.
	Bridge string `yaml:"address"`
	// Confirmations is the number of required confirmations
	Confirmations uint64 `yaml:"confirmations"`
	// Tokens is a map of token ID -> token config.
	Tokens map[string]TokenConfig `yaml:"tokens"`
	// NativeToken is the native token of the chain (pays gas).
	NativeToken string `yaml:"native_token"`
	// DeadlineBufferSeconds is the deadline buffer for relaying a transaction.
	DeadlineBufferSeconds int `yaml:"deadline_buffer_seconds"`
}

ChainConfig represents the configuration for a chain.

type ChainFeeParams added in v0.0.17

type ChainFeeParams struct {
	// OriginGasEstimate is the gas estimate to use for origin transactions (this will override base gas estimates).
	OriginGasEstimate int `yaml:"origin_gas_estimate"`
	// DestGasEstimate is the gas estimate to use for destination transactions (this will override base gas estimates).
	DestGasEstimate int `yaml:"dest_gas_estimate"`
	// L1FeeChainID indicates the chain ID for the L1 fee (if needed, for example on optimism).
	L1FeeChainID uint32 `yaml:"l1_fee_chain_id"`
	// L1FeeOriginGasEstimate is the gas estimate for the L1 fee on origin.
	L1FeeOriginGasEstimate int `yaml:"l1_fee_origin_gas_estimate"`
	// L1FeeDestGasEstimate is the gas estimate for the L1 fee on destination.
	L1FeeDestGasEstimate int `yaml:"l1_fee_dest_gas_estimate"`
}

ChainFeeParams represents the chain fee params.

type Config

type Config struct {
	// Chains is a map of chainID -> chain config.
	Chains map[int]ChainConfig `yaml:"bridges"`
	// OmniRPCURL is the URL of the OmniRPC server.
	OmniRPCURL string `yaml:"omnirpc_url"`
	// RfqAPIURL is the URL of the RFQ API.
	RfqAPIURL string `yaml:"rfq_url"`
	// RelayerAPIPort is the port of the relayer API.
	RelayerAPIPort string `yaml:"relayer_api_port"`
	// Database is the database config.
	Database DatabaseConfig `yaml:"database"`
	// QuotableTokens is a map of token -> list of quotable tokens.
	QuotableTokens map[string][]string `yaml:"quotable_tokens"`
	// Signer is the signer config.
	Signer config.SignerConfig `yaml:"signer"`
	// Submitter is the submitter config.
	SubmitterConfig submitterConfig.Config `yaml:"submitter_config"`
	// FeePricer is the fee pricer config.
	FeePricer FeePricerConfig `yaml:"fee_pricer"`
	// QuotePct is the percent of balance to quote.
	QuotePct float64 `yaml:"quote_pct"`
	// ScreenerAPIUrl is the TRM API key.
	ScreenerAPIUrl string `yaml:"screener_api_url"`
	// BaseDeadlineBufferSeconds is the deadline buffer for relaying a transaction.
	BaseDeadlineBufferSeconds int `yaml:"base_deadline_buffer_seconds"`
}

Config represents the configuration for the relayer. TODO: validation function.

func LoadConfig

func LoadConfig(path string) (config Config, err error)

LoadConfig loads the config from the given path.

func (Config) GetChains

func (c Config) GetChains() map[int]ChainConfig

GetChains returns the chains config.

func (Config) GetDatabase

func (c Config) GetDatabase() DatabaseConfig

GetDatabase returns the database config.

func (Config) GetDeadlineBuffer added in v0.0.23

func (c Config) GetDeadlineBuffer(chainID int) time.Duration

GetDeadlineBuffer returns the deadline buffer for relaying a transaction.

func (Config) GetDestGasEstimate added in v0.0.17

func (c Config) GetDestGasEstimate(chainID uint32) int

GetDestGasEstimate returns the destination gas estimate for the given chain.

func (Config) GetFeePricer

func (c Config) GetFeePricer() FeePricerConfig

GetFeePricer returns the fee pricer config.

func (Config) GetFixedFeeMultiplier added in v0.0.6

func (c Config) GetFixedFeeMultiplier() float64

GetFixedFeeMultiplier returns the fixed fee multiplier.

func (Config) GetL1FeeParams added in v0.0.17

func (c Config) GetL1FeeParams(chainID uint32, origin bool) (uint32, int, bool)

GetL1FeeParams returns the L1 fee params for the given chain.

func (Config) GetMinQuoteAmount added in v0.0.16

func (c Config) GetMinQuoteAmount(chainID int, addr common.Address) *big.Int

GetMinQuoteAmount returns the quote amount for the given chain and address. Note that this getter returns the value in native token decimals.

func (Config) GetNativeToken

func (c Config) GetNativeToken(chainID uint32) (string, error)

GetNativeToken returns the native token for the given chain.

func (Config) GetOmniRPCURL

func (c Config) GetOmniRPCURL() string

GetOmniRPCURL returns the OmniRPCURL.

func (Config) GetOriginGasEstimate added in v0.0.17

func (c Config) GetOriginGasEstimate(chainID uint32) int

GetOriginGasEstimate returns the origin gas estimate for the given chain.

func (Config) GetQuotableTokens

func (c Config) GetQuotableTokens(token string) ([]string, error)

GetQuotableTokens returns the quotable tokens for the given token.

func (Config) GetQuotePct added in v0.0.16

func (c Config) GetQuotePct() float64

GetQuotePct returns the quote percentage.

func (Config) GetRfqAPIURL

func (c Config) GetRfqAPIURL() string

GetRfqAPIURL returns the RFQ API URL.

func (Config) GetSigner

func (c Config) GetSigner() config.SignerConfig

GetSigner returns the signer config.

func (Config) GetTokenDecimals

func (c Config) GetTokenDecimals(chainID uint32, token string) (uint8, error)

GetTokenDecimals returns the token decimals for the given chain and token.

func (Config) GetTokenID

func (c Config) GetTokenID(chain int, addr string) (string, error)

GetTokenID returns the tokenID for the given chain and address.

func (Config) GetTokenName

func (c Config) GetTokenName(chain uint32, addr string) (string, error)

GetTokenName returns the token name for the given chain and address.

func (Config) GetTokens

func (c Config) GetTokens(chainID uint32) (map[string]TokenConfig, error)

GetTokens returns the tokens for the given chain.

type DatabaseConfig

type DatabaseConfig struct {
	Type string `yaml:"type"`
	DSN  string `yaml:"dsn"` // Data Source Name
}

DatabaseConfig represents the configuration for the database.

type FeePricerConfig

type FeePricerConfig struct {
	// BaseOriginGasEstimate is the gas required to execute prove + claim transactions on origin chain.
	BaseOriginGasEstimate int `yaml:"base_origin_gas_estimate"`
	// BaseDestGasEstimate is the gas required to execute relay transaction on destination chain.
	BaseDestGasEstimate int `yaml:"base_dest_gas_estimate"`
	// FixedFeeMultiplier is the multiplier for the fixed fee.
	FixedFeeMultiplier float64 `yaml:"fixed_fee_multiplier"`
	// GasPriceCacheTTLSeconds is the TTL for the gas price cache.
	GasPriceCacheTTLSeconds int `yaml:"gas_price_cache_ttl"`
	// TokenPriceCacheTTLSeconds is the TTL for the token price cache.
	TokenPriceCacheTTLSeconds int `yaml:"token_price_cache_ttl"`
	// ChainFeeParams are parameters that correspond to specific chains.
	ChainFeeParams map[uint32]ChainFeeParams `yaml:"chain_fee_params"`
}

FeePricerConfig represents the configuration for the fee pricer.

type IConfig

type IConfig interface {
	// GetChains returns the chains config.
	GetChains() map[int]ChainConfig
	// GetOmniRPCURL returns the OmniRPCURL.
	GetOmniRPCURL() string
	// GetRfqAPIURL returns the RFQ API URL.
	GetRfqAPIURL() string
	// GetDatabase returns the database config.
	GetDatabase() DatabaseConfig
	// GetSigner returns the signer config.
	GetSigner() config.SignerConfig
	// GetFeePricer returns the fee pricer config.
	GetFeePricer() FeePricerConfig
	// GetTokenID returns the tokenID for the given chain and address.
	GetTokenID(chain int, addr string) (string, error)
	// GetQuotableTokens returns the quotable tokens for the given token.
	GetQuotableTokens(token string) ([]string, error)
	// GetNativeToken returns the native token for the given chain.
	GetNativeToken(chainID uint32) (string, error)
	// GetTokenDecimals returns the token decimals for the given chain and token.
	GetTokenDecimals(chainID uint32, token string) (uint8, error)
	// GetTokens returns the tokens for the given chain.
	GetTokens(chainID uint32) (map[string]TokenConfig, error)
	// GetTokenName returns the token name for the given chain and address.
	GetTokenName(chain uint32, addr string) (string, error)
	// GetFixedFeeMultiplier returns the fixed fee multiplier.
	GetFixedFeeMultiplier() float64
	// GetOriginGasEstimate returns the origin gas estimate for the given chain.
	GetOriginGasEstimate(chainID uint32) int
	// GetDestGasEstimate returns the destination gas estimate for the given chain.
	GetDestGasEstimate(chainID uint32) int
	// GetL1FeeParams returns the L1 fee params for the given chain.
	GetL1FeeParams(chainID uint32, origin bool) (uint32, int, bool)
	// GetQuotePct returns the quote percentage.
	GetQuotePct() float64
	// GetMinQuoteAmount returns the quote amount for the given chain and address.
	// Note that this getter returns the value in native token decimals.
	GetMinQuoteAmount(chainID int, addr common.Address) *big.Int
	// GetDeadlineBuffer returns the deadline buffer for relaying a transaction.
	GetDeadlineBuffer(chainID int) time.Duration
}

IConfig ...

type TokenConfig

type TokenConfig struct {
	// Address is the token address.
	Address string `yaml:"address"`
	// Decimals is the token decimals.
	Decimals uint8 `yaml:"decimals"`
	// For now, specify the USD price of the token in the config.
	PriceUSD float64 `yaml:"price_usd"`
	// MinQuoteAmount is the minimum amount to quote for this token in human-readable units.
	MinQuoteAmount string `yaml:"min_quote_amount"`
}

TokenConfig represents the configuration for a token.

Jump to

Keyboard shortcuts

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