Documentation ¶
Overview ¶
Package relconfig contains the config yaml object for the relayer.
Index ¶
- Constants
- Variables
- func DecodeTokenID(id string) (chainID int, addr common.Address, err error)
- func NewFloatPtr(val float64) *float64
- func SanitizeTokenID(id string) (sanitized string, err error)
- type ChainConfig
- type CircleCCTPRebalanceConfig
- type Config
- func (c Config) GetAllRebalanceMethods() (allMethods map[RebalanceMethod]bool, err error)
- func (c Config) GetChains() map[int]ChainConfig
- func (c Config) GetConfirmations(chainID int) (value uint64, err error)
- func (c Config) GetDBSelectorInterval() time.Duration
- func (c Config) GetDatabase() DatabaseConfig
- func (c Config) GetDeadlineBuffer(chainID int) (seconds time.Duration, err error)
- func (c Config) GetDestGasEstimate(chainID int) (value int, err error)
- func (c Config) GetFeePricer() FeePricerConfig
- func (c Config) GetFinalityConfirmations(chainID int) (value uint64, err error)
- func (c Config) GetHTTPTimeout() time.Duration
- func (c Config) GetInitialBalancePct(chainID int, tokenAddr string) (float64, error)
- func (c Config) GetL1FeeChainID(chainID int) (value uint32, err error)
- func (c Config) GetL1FeeDestGasEstimate(chainID int) (value int, err error)
- func (c Config) GetL1FeeOriginGasEstimate(chainID int) (value int, err error)
- func (c Config) GetL1FeeParams(chainID uint32, origin bool) (uint32, int, bool)
- func (c Config) GetL1GatewayAddress(chainID int) (value common.Address, err error)
- func (c Config) GetL1ScrollMessengerAddress(chainID int) (value common.Address, err error)
- func (c Config) GetL2GatewayAddress(chainID int) (value common.Address, err error)
- func (c Config) GetMaintenanceBalancePct(chainID int, tokenAddr string) (float64, error)
- func (c Config) GetMaxBalance(chainID int, addr common.Address) *big.Int
- func (c Config) GetMaxRebalanceAmount(chainID int, addr common.Address) *big.Int
- func (c Config) GetMaxRelayAmount(chainID int, addr common.Address) *big.Int
- func (c Config) GetMinGasToken(chainID int) (value *big.Int, err error)
- func (c Config) GetMinQuoteAmount(chainID int, addr common.Address) *big.Int
- func (c Config) GetMinRebalanceAmount(chainID int, addr common.Address) *big.Int
- func (c Config) GetNativeToken(chainID int) (value string, err error)
- func (c Config) GetOmniRPCURL() string
- func (c Config) GetOriginGasEstimate(chainID int) (value int, err error)
- func (c Config) GetQuotableTokens(token string) ([]string, error)
- func (c Config) GetQuoteFixedFeeMultiplier(chainID int) (value float64, err error)
- func (c Config) GetQuoteOffsetBps(chainID int, tokenName string, isOrigin bool) (value float64, err error)
- func (c Config) GetQuotePct(chainID int) (value float64, err error)
- func (c Config) GetQuoteSubmissionTimeout() time.Duration
- func (c Config) GetQuoteWidthBps(chainID int) (value float64, err error)
- func (c Config) GetRFQAPIURL() string
- func (c Config) GetRFQAddress(chainID int) (value common.Address, err error)
- func (c Config) GetRebalanceInterval() time.Duration
- func (c Config) GetRebalanceMethods(chainID int, tokenAddr string) (methods []RebalanceMethod, err error)
- func (c Config) GetRebalanceStartBlock(chainID int) (value uint64, err error)
- func (c Config) GetRelayFixedFeeMultiplier(chainID int) (value float64, err error)
- func (c Config) GetScrollMessageFee(chainID int) (value *big.Int, err error)
- func (c Config) GetSigner() config.SignerConfig
- func (c Config) GetSynapseCCTPAddress(chainID int) (value common.Address, err error)
- func (c Config) GetTokenDecimals(chainID uint32, token string) (uint8, error)
- func (c Config) GetTokenID(chain int, addr string) (string, error)
- func (c Config) GetTokenMessengerAddress(chainID int) (value common.Address, err error)
- func (c Config) GetTokenName(chain uint32, addr string) (string, error)
- func (c Config) GetTokens(chainID uint32) (map[string]TokenConfig, error)
- func (c Config) GetVolumeLimit(chainID int, addr common.Address) *big.Int
- func (c Config) Validate(ctx context.Context, omniclient omniClient.RPCClient) (err error)
- type DatabaseConfig
- type FeePricerConfig
- type RebalanceConfigs
- type RebalanceMethod
- type ScrollRebalanceConfig
- type SynapseCCTPRebalanceConfig
- type TokenConfig
Constants ¶
const TokenIDDelimiter = "-"
TokenIDDelimiter is the delimiter for token IDs.
Variables ¶
var DefaultChainConfig = ChainConfig{ DeadlineBufferSeconds: 600, OriginGasEstimate: 160000, DestGasEstimate: 100000, MinGasToken: "100000000000000000", QuotePct: NewFloatPtr(100), QuoteWidthBps: 0, QuoteFixedFeeMultiplier: NewFloatPtr(1), RelayFixedFeeMultiplier: NewFloatPtr(1), }
DefaultChainConfig is the default chain config.
Functions ¶
func DecodeTokenID ¶ added in v0.29.11
DecodeTokenID decodes a token ID into a chain ID and address.
func NewFloatPtr ¶ added in v0.34.4
NewFloatPtr returns a pointer to a float64.
func SanitizeTokenID ¶ added in v0.0.36
SanitizeTokenID takes a raw string, makes sure it is a valid token ID, and returns the token ID as string with a checksummed address.
Types ¶
type ChainConfig ¶
type ChainConfig struct { // Bridge is the rfq bridge contract address. RFQAddress string `yaml:"rfq_address"` // Confirmations is the number of required confirmations. Confirmations uint64 `yaml:"confirmations"` // FinalityConfirmations is the number of required confirmations before proving. FinalityConfirmations uint64 `yaml:"prove_confirmations"` // Tokens is a map of token name -> 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"` // 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"` // MinGasToken is minimum amount of gas that should be leftover after bridging a gas token. MinGasToken string `yaml:"min_gas_token"` // QuotePct is the percent of balance to quote. QuotePct *float64 `yaml:"quote_pct"` // QuoteWidthBps is the number of basis points to deduct from the dest amount. // Note that this parameter is applied on a chain level and must be positive. QuoteWidthBps float64 `yaml:"quote_width_bps"` // QuoteFixedFeeMultiplier is the multiplier for the fixed fee, applied when generating quotes. QuoteFixedFeeMultiplier *float64 `yaml:"quote_fixed_fee_multiplier"` // RelayFixedFeeMultiplier is the multiplier for the fixed fee, applied when relaying. RelayFixedFeeMultiplier *float64 `yaml:"relay_fixed_fee_multiplier"` // RebalanceStartBlock is the block at which the chain listener will listen for rebalance events. RebalanceStartBlock uint64 `yaml:"cctp_start_block"` // RebalanceConfigs is the rebalance configurations. RebalanceConfigs RebalanceConfigs `yaml:"rebalance_configs"` // LimitConfirmations is the number of confirmations to wait for before processing a quote. LimitConfirmations uint64 `yaml:"limit_confirmations"` }
ChainConfig represents the configuration for a chain.
type CircleCCTPRebalanceConfig ¶ added in v1.1.4
type CircleCCTPRebalanceConfig struct { // TokenMessengerAddress is the TokenMessenger address. TokenMessengerAddress string `yaml:"token_messenger_address"` }
CircleCCTPRebalanceConfig represents the configuration for the CircleCCTP rebalance.
type Config ¶
type Config struct { // Chains is a map of chainID -> chain config. Chains map[int]ChainConfig `yaml:"chains"` // BaseChainConfig applies to all chains except those values that are overridden in Chains. BaseChainConfig ChainConfig `yaml:"base_chain_config"` // 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"` // SubmitterConfig is the submitter config. SubmitterConfig submitterConfig.Config `yaml:"submitter_config"` // FeePricer is the fee pricer config. FeePricer FeePricerConfig `yaml:"fee_pricer"` // ScreenerAPIUrl is the TRM API url. ScreenerAPIUrl string `yaml:"screener_api_url"` // DBSelectorInterval is the interval for the db selector. DBSelectorInterval time.Duration `yaml:"db_selector_interval"` // RebalanceInterval is the interval for rebalancing. RebalanceInterval time.Duration `yaml:"rebalance_interval"` // QuoteSubmissionTimeout is the timeout for submitting a quote. QuoteSubmissionTimeout time.Duration `yaml:"quote_submission_timeout"` // CCTPRelayerConfig is the embedded cctp relayer config (optional). CCTPRelayerConfig *cctpConfig.Config `yaml:"cctp_relayer_config"` // EnableAPIWithdrawals enables withdrawals via the API. EnableAPIWithdrawals bool `yaml:"enable_api_withdrawals"` // WithdrawalWhitelist is a list of addresses that are allowed to withdraw. WithdrawalWhitelist []string `yaml:"withdrawal_whitelist"` // UseEmbeddedGuard enables the embedded guard. UseEmbeddedGuard bool `yaml:"enable_guard"` // SubmitSingleQuotes enables submitting single quotes. SubmitSingleQuotes bool `yaml:"submit_single_quotes"` // VolumeLimit is the maximum dollar value of relayed transactions in the BlockWindow. VolumeLimit float64 `yaml:"volume_limit"` // SupportActiveQuoting enables support for active quoting. SupportActiveQuoting bool `yaml:"support_active_quoting"` }
Config represents the configuration for the relayer.
func LoadConfig ¶
LoadConfig loads the config from the given path.
func (Config) GetAllRebalanceMethods ¶ added in v1.1.4
func (c Config) GetAllRebalanceMethods() (allMethods map[RebalanceMethod]bool, err error)
GetAllRebalanceMethods returns all rebalance methods present in the config.
func (Config) GetChains ¶
func (c Config) GetChains() map[int]ChainConfig
GetChains returns the chains config.
func (Config) GetConfirmations ¶ added in v0.0.39
GetConfirmations returns the Confirmations for the given chainID.
func (Config) GetDBSelectorInterval ¶ added in v0.0.44
GetDBSelectorInterval returns the interval for the DB selector.
func (Config) GetDatabase ¶
func (c Config) GetDatabase() DatabaseConfig
GetDatabase returns the database config.
func (Config) GetDeadlineBuffer ¶ added in v0.0.23
GetDeadlineBuffer returns the DeadlineBuffer for the given chainID.
func (Config) GetDestGasEstimate ¶ added in v0.0.17
GetDestGasEstimate returns the DestGasEstimate for the given chainID.
func (Config) GetFeePricer ¶
func (c Config) GetFeePricer() FeePricerConfig
GetFeePricer returns the fee pricer config.
func (Config) GetFinalityConfirmations ¶ added in v1.20.0
GetFinalityConfirmations returns the FinalityConfirmations for the given chainID.
func (Config) GetHTTPTimeout ¶ added in v0.0.40
GetHTTPTimeout returns the HTTP timeout.
func (Config) GetInitialBalancePct ¶ added in v0.0.54
GetInitialBalancePct returns the initial balance percentage for the given chain and token address.
func (Config) GetL1FeeChainID ¶ added in v0.0.39
GetL1FeeChainID returns the L1FeeChainID for the given chainID.
func (Config) GetL1FeeDestGasEstimate ¶ added in v0.0.39
GetL1FeeDestGasEstimate returns the L1FeeDestGasEstimate for the given chainID.
func (Config) GetL1FeeOriginGasEstimate ¶ added in v0.0.39
GetL1FeeOriginGasEstimate returns the L1FeeOriginGasEstimate for the given chainID.
func (Config) GetL1FeeParams ¶ added in v0.0.17
GetL1FeeParams returns the L1 fee params for the given chain.
func (Config) GetL1GatewayAddress ¶ added in v1.1.4
GetL1GatewayAddress returns the L1Gateway address for the given chainID.
func (Config) GetL1ScrollMessengerAddress ¶ added in v1.1.4
GetL1ScrollMessengerAddress returns the L1ScrollMessenger address for the given chainID.
func (Config) GetL2GatewayAddress ¶ added in v1.1.4
GetL2GatewayAddress returns the L2Gateway address for the given chainID.
func (Config) GetMaintenanceBalancePct ¶ added in v0.0.54
GetMaintenanceBalancePct returns the maintenance balance percentage for the given chain and token address.
func (Config) GetMaxBalance ¶ added in v1.4.0
GetMaxBalance returns the MaxBalance for the given chain and address. Note that this getter returns the value in native token decimals.
func (Config) GetMaxRebalanceAmount ¶ added in v0.0.54
GetMaxRebalanceAmount returns the max rebalance amount for the given chain and address. Note that this getter returns the value in native token decimals.
func (Config) GetMaxRelayAmount ¶ added in v1.32.0
GetMaxRelayAmount returns the quote amount for the given chain and address. Note that this getter returns the value in native token decimals.
func (Config) GetMinGasToken ¶ added in v0.0.35
GetMinGasToken returns the MinGasToken for the given chainID.
func (Config) GetMinQuoteAmount ¶ added in v0.0.16
GetMinQuoteAmount returns the quote amount for the given chain and address. Note that this getter returns the value in native token decimals.
func (Config) GetMinRebalanceAmount ¶ added in v0.3.0
GetMinRebalanceAmount returns the min rebalance amount for the given chain and address. Note that this getter returns the value in native token decimals.
func (Config) GetNativeToken ¶
GetNativeToken returns the NativeToken for the given chainID.
func (Config) GetOmniRPCURL ¶
GetOmniRPCURL returns the OmniRPCURL.
func (Config) GetOriginGasEstimate ¶ added in v0.0.17
GetOriginGasEstimate returns the OriginGasEstimate for the given chainID.
func (Config) GetQuotableTokens ¶
GetQuotableTokens returns the quotable tokens for the given token.
func (Config) GetQuoteFixedFeeMultiplier ¶ added in v0.23.1
GetQuoteFixedFeeMultiplier returns the QuoteFixedFeeMultiplier for the given chainID.
func (Config) GetQuoteOffsetBps ¶ added in v0.0.31
func (c Config) GetQuoteOffsetBps(chainID int, tokenName string, isOrigin bool) (value float64, err error)
GetQuoteOffsetBps returns the QuoteOffsetBps for the given chainID and tokenAddr. If the chainID corresponds to the origin of a quote, we flip the sign.
func (Config) GetQuotePct ¶ added in v0.0.16
GetQuotePct returns the QuotePct for the given chainID.
func (Config) GetQuoteSubmissionTimeout ¶ added in v0.13.0
GetQuoteSubmissionTimeout returns the timeout for submitting quotes.
func (Config) GetQuoteWidthBps ¶ added in v0.15.1
GetQuoteWidthBps returns the QuoteWidthBps for the given chainID.
func (Config) GetRFQAPIURL ¶ added in v1.29.0
GetRFQAPIURL returns the RFQ API URL.
func (Config) GetRFQAddress ¶ added in v0.0.54
GetRFQAddress returns the RFQ address for the given chainID.
func (Config) GetRebalanceInterval ¶ added in v0.0.54
GetRebalanceInterval returns the interval for rebalancing.
func (Config) GetRebalanceMethods ¶ added in v0.0.54
func (c Config) GetRebalanceMethods(chainID int, tokenAddr string) (methods []RebalanceMethod, err error)
GetRebalanceMethods returns the rebalance method for the given chain path and token address. This method will error if there is a rebalance method mismatch, and neither methods correspond to RebalanceMethodsNone.
func (Config) GetRebalanceStartBlock ¶ added in v1.1.4
GetRebalanceStartBlock returns the RebalanceStartBlock for the given chainID.
func (Config) GetRelayFixedFeeMultiplier ¶ added in v0.23.1
GetRelayFixedFeeMultiplier returns the RelayFixedFeeMultiplier for the given chainID.
func (Config) GetScrollMessageFee ¶ added in v1.1.4
GetScrollMessageFee returns the ScrollMessageFee for the given chainID.
func (Config) GetSigner ¶
func (c Config) GetSigner() config.SignerConfig
GetSigner returns the signer config.
func (Config) GetSynapseCCTPAddress ¶ added in v0.5.0
GetSynapseCCTPAddress returns the SynapseCCTP address for the given chainID.
func (Config) GetTokenDecimals ¶
GetTokenDecimals returns the token decimals for the given chain and token.
func (Config) GetTokenID ¶
GetTokenID returns the tokenID for the given chain and address.
func (Config) GetTokenMessengerAddress ¶ added in v0.5.0
GetTokenMessengerAddress returns the TokenMessenger address for the given chainID.
func (Config) GetTokenName ¶
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.
func (Config) GetVolumeLimit ¶ added in v1.24.0
GetVolumeLimit returns the volume limit for the relayer.
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 { // 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"` // HTTPTimeoutMs is the number of milliseconds to timeout on a HTTP request. HTTPTimeoutMs int `yaml:"http_timeout_ms"` }
FeePricerConfig represents the configuration for the fee pricer.
type RebalanceConfigs ¶ added in v1.1.4
type RebalanceConfigs struct { Synapse *SynapseCCTPRebalanceConfig `yaml:"synapse"` Circle *CircleCCTPRebalanceConfig `yaml:"circle"` Scroll *ScrollRebalanceConfig `yaml:"scroll"` }
RebalanceConfigs represents the rebalance configurations.
type RebalanceMethod ¶ added in v0.0.54
type RebalanceMethod uint8
RebalanceMethod is the method to rebalance.
const ( // RebalanceMethodNone is the default rebalance method. RebalanceMethodNone RebalanceMethod = iota // RebalanceMethodSynapseCCTP is the rebalance method for CCTP. RebalanceMethodSynapseCCTP // RebalanceMethodCircleCCTP is the rebalance method for Circle CCTP. RebalanceMethodCircleCCTP // RebalanceMethodScroll is the rebalance method for Scroll. RebalanceMethodScroll )
func RebalanceMethodFromString ¶ added in v0.16.0
func RebalanceMethodFromString(str string) (RebalanceMethod, error)
RebalanceMethodFromString converts a string to a RebalanceMethod.
func (RebalanceMethod) String ¶ added in v0.0.54
func (i RebalanceMethod) String() string
type ScrollRebalanceConfig ¶ added in v1.1.4
type ScrollRebalanceConfig struct { // L1GatewayAddress is the L1Gateway address [scroll]. L1GatewayAddress string `yaml:"l1_gateway_address"` // L1ScrollMessengerAddress is the L1ScrollMessenger address [scroll]. L1ScrollMessengerAddress string `yaml:"l1_scroll_messenger_address"` // L2GatewayAddress is the L2Gateway address [scroll]. L2GatewayAddress string `yaml:"l2_gateway_address"` // ScrollMessageFee is the scroll message fee. ScrollMessageFee *string `yaml:"scroll_message_fee"` }
ScrollRebalanceConfig represents the configuration for the Scroll rebalance.
type SynapseCCTPRebalanceConfig ¶ added in v1.1.4
type SynapseCCTPRebalanceConfig struct { // SynapseCCTPAddress is the SynapseCCTP address. SynapseCCTPAddress string `yaml:"synapse_cctp_address"` }
SynapseCCTPRebalanceConfig represents the configuration for the SynapseCCTP rebalance.
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"` // MaxRelayAmount is the maximum amount to quote and relay for this token in human-readable units. MaxRelayAmount string `yaml:"max_relay_amount"` // RebalanceMethods are the supported methods for rebalancing. RebalanceMethods []string `yaml:"rebalance_methods"` // MaintenanceBalancePct is the percentage of the total balance under which a rebalance will be triggered. MaintenanceBalancePct float64 `yaml:"maintenance_balance_pct"` // InitialBalancePct is the percentage of the total balance to retain when triggering a rebalance. InitialBalancePct float64 `yaml:"initial_balance_pct"` // MinRebalanceAmount is the minimum amount to rebalance in human-readable units. // For USDC-through-cctp pairs this defaults to $1,000. MinRebalanceAmount string `yaml:"min_rebalance_amount"` // MaxRebalanceAmount is the maximum amount to rebalance in human-readable units. MaxRebalanceAmount string `yaml:"max_rebalance_amount"` // QuoteOffsetBps is the number of basis points to deduct from the dest amount, // and add to the origin amount for a given token, // Note that this value can be positive or negative; if positive it effectively increases the quoted price // of the given token, and vice versa. QuoteOffsetBps float64 `yaml:"quote_offset_bps"` // MaxBalance is the maximum balance that should be accumulated for this token on this chain (human-readable units) MaxBalance *string `yaml:"max_balance"` }
TokenConfig represents the configuration for a token.