params

package
v3.0.0-...-fa64414 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package params provides common version info and config items.

Index

Constants

View Source
const (
	VersionMajor = 3  // Major version component of the current release
	VersionMinor = 3  // Minor version component of the current release
	VersionPatch = 0  // Patch version component of the current release
	VersionMeta  = "" // Version metadata to append to the version string
)

version parts

View Source
const (
	RouterSwapPrefixID = "routerswap"
)

router swap constants

Variables

View Source
var Version = func() string {
	return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}()

Version holds the textual version string.

View Source
var VersionWithMeta = func() string {
	v := Version
	if VersionMeta != "" {
		v += "-" + VersionMeta
	}
	return v
}()

VersionWithMeta holds the textual version string including the metadata.

Functions

func AllowCallByContract

func AllowCallByContract() bool

AllowCallByContract allow call into router from contract

func CallContractWithGateway

func CallContractWithGateway(gateway, contract string, data hexutil.Bytes, blockNumber string) (result string, err error)

CallContractWithGateway call eth_call

func GetAcceptListInterval

func GetAcceptListInterval() uint64

GetAcceptListInterval get accept list interval (seconds)

func GetBaseFeePercent

func GetBaseFeePercent(chainID string) int64

GetBaseFeePercent get base fee percent

func GetDataDir

func GetDataDir() string

GetDataDir get data dir

func GetFixedGasPrice

func GetFixedGasPrice(chainID string) *big.Int

GetFixedGasPrice get fixed gas price of specified chain

func GetIdentifier

func GetIdentifier() string

GetIdentifier get identifier (to distiguish in mpc accept)

func GetMaxGasPrice

func GetMaxGasPrice(chainID string) *big.Int

GetMaxGasPrice get max gas price of specified chain

func GetMinReserveFee

func GetMinReserveFee(chainID string) *big.Int

GetMinReserveFee get min reserve fee

func GetNoncePassedConfirmInterval

func GetNoncePassedConfirmInterval(chainID string) int64

GetNoncePassedConfirmInterval get nonce passed confirm interval

func GetOnchainContract

func GetOnchainContract() string

GetOnchainContract get onchain config contract address

func GetSwapType

func GetSwapType() string

GetSwapType get router swap type

func HasRouterAdmin

func HasRouterAdmin() bool

HasRouterAdmin has admin

func IsChainIDInBlackList

func IsChainIDInBlackList(chainID string) bool

IsChainIDInBlackList is chain id in black list

func IsCheckTxBlockHashEnabled

func IsCheckTxBlockHashEnabled(chainID string) bool

IsCheckTxBlockHashEnabled check tx block hash

func IsCheckTxBlockIndexEnabled

func IsCheckTxBlockIndexEnabled(chainID string) bool

IsCheckTxBlockIndexEnabled check tx block and index

func IsDebugMode

func IsDebugMode() bool

IsDebugMode is debug mode, add more debugging log infos

func IsDynamicFeeTxEnabled

func IsDynamicFeeTxEnabled(chainID string) bool

IsDynamicFeeTxEnabled is dynamic fee tx enabled (EIP-1559)

func IsInBigValueWhitelist

func IsInBigValueWhitelist(tokenID, caller string) bool

IsInBigValueWhitelist is in call by contract whitelist

func IsInCallByContractWhitelist

func IsInCallByContractWhitelist(chainID, caller string) bool

IsInCallByContractWhitelist is in call by contract whitelist

func IsMPCInitiator

func IsMPCInitiator(account string) bool

IsMPCInitiator is initiator of mpc sign

func IsRouterAdmin

func IsRouterAdmin(account string) bool

IsRouterAdmin is admin

func IsSwapInBlacklist

func IsSwapInBlacklist(fromChainID, toChainID, tokenID string) bool

IsSwapInBlacklist is chain or token blacklisted

func IsTokenIDInBlackList

func IsTokenIDInBlackList(tokenID string) bool

IsTokenIDInBlackList is token id in black list

func SetAllowCallByContract

func SetAllowCallByContract(allow bool)

SetAllowCallByContract set allow call by contract flag (used in testing)

func SetDataDir

func SetDataDir(dir string, isServer bool)

SetDataDir set data dir

func VersionWithCommit

func VersionWithCommit(gitCommit, gitDate string) string

VersionWithCommit add git commit and data to version.

Types

type APIServerConfig

type APIServerConfig struct {
	Port           int
	AllowedOrigins []string
}

APIServerConfig api service config

type DynamicFeeTxConfig

type DynamicFeeTxConfig struct {
	PlusGasTipCapPercent uint64
	PlusGasFeeCapPercent uint64
	BlockCountFeeHistory int
	MaxGasTipCap         string
	MaxGasFeeCap         string
	// contains filtered or unexported fields
}

DynamicFeeTxConfig dynamic fee tx config

func GetDynamicFeeTxConfig

func GetDynamicFeeTxConfig(chainID string) *DynamicFeeTxConfig

GetDynamicFeeTxConfig get dynamic fee tx config (EIP-1559)

func (*DynamicFeeTxConfig) GetMaxGasFeeCap

func (c *DynamicFeeTxConfig) GetMaxGasFeeCap() *big.Int

GetMaxGasFeeCap get max fee gas cap

func (*DynamicFeeTxConfig) GetMaxGasTipCap

func (c *DynamicFeeTxConfig) GetMaxGasTipCap() *big.Int

GetMaxGasTipCap get max gas tip cap

type ExtraConfig

type ExtraConfig struct {
	IsDebugMode    bool              `toml:",omitempty" json:",omitempty"`
	MinReserveFee  map[string]uint64 `toml:",omitempty" json:",omitempty"`
	BaseFeePercent map[string]int64  `toml:",omitempty" json:",omitempty"` // key is chain ID

	GetAcceptListInterval uint64 `toml:",omitempty" json:",omitempty"`

	AllowCallByContract     bool
	CallByContractWhitelist map[string][]string // chainID -> whitelist
	BigValueWhitelist       map[string][]string // tokenID -> whitelist

	DynamicFeeTxEnabledChains     []string
	EnableCheckTxBlockHashChains  []string
	EnableCheckTxBlockIndexChains []string
}

ExtraConfig extra config

func GetExtraConfig

func GetExtraConfig() *ExtraConfig

GetExtraConfig get extra config

func (*ExtraConfig) CheckConfig

func (c *ExtraConfig) CheckConfig() (err error)

CheckConfig check extra config

type MPCConfig

type MPCConfig struct {
	APIPrefix     string
	RPCTimeout    uint64
	SignTimeout   uint64
	GroupID       *string
	NeededOracles *uint32
	TotalOracles  *uint32
	Mode          uint32 // 0:managed 1:private (default 0)
	Initiators    []string
	DefaultNode   *MPCNodeConfig
	OtherNodes    []*MPCNodeConfig `toml:",omitempty" json:",omitempty"`
}

MPCConfig mpc related config

func (*MPCConfig) CheckConfig

func (c *MPCConfig) CheckConfig(isServer bool) (err error)

CheckConfig check mpc config

type MPCNodeConfig

type MPCNodeConfig struct {
	RPCAddress   *string
	SignGroups   []string `toml:",omitempty" json:",omitempty"`
	KeystoreFile *string  `json:"-"`
	PasswordFile *string  `json:"-"`
}

MPCNodeConfig mpc node config

func (*MPCNodeConfig) CheckConfig

func (c *MPCNodeConfig) CheckConfig(isServer bool) (err error)

CheckConfig check mpc node config

type MongoDBConfig

type MongoDBConfig struct {
	DBURL    string   `toml:",omitempty" json:",omitempty"`
	DBURLs   []string `toml:",omitempty" json:",omitempty"`
	DBName   string
	UserName string `json:"-"`
	Password string `json:"-"`
}

MongoDBConfig mongodb config

func (*MongoDBConfig) CheckConfig

func (c *MongoDBConfig) CheckConfig() error

CheckConfig check mongodb config

type OnchainConfig

type OnchainConfig struct {
	Contract    string
	APIAddress  []string
	WSServers   []string
	ReloadCycle uint64 // seconds
}

OnchainConfig struct

func (*OnchainConfig) CheckConfig

func (c *OnchainConfig) CheckConfig() error

CheckConfig check onchain config storing chain and token configs

type RouterConfig

type RouterConfig struct {
	Server *RouterServerConfig `toml:",omitempty" json:",omitempty"`

	Identifier  string
	SwapType    string
	Onchain     *OnchainConfig
	Gateways    map[string][]string // key is chain ID
	GatewaysExt map[string][]string `toml:",omitempty" json:",omitempty"` // key is chain ID
	MPC         *MPCConfig
	Extra       *ExtraConfig `toml:",omitempty" json:",omitempty"`
}

RouterConfig config

func GetRouterConfig

func GetRouterConfig() *RouterConfig

GetRouterConfig get router config

func LoadRouterConfig

func LoadRouterConfig(configFile string, isServer bool) *RouterConfig

LoadRouterConfig load router swap config

func (*RouterConfig) CheckConfig

func (config *RouterConfig) CheckConfig(isServer bool) (err error)

CheckConfig check router config

type RouterServerConfig

type RouterServerConfig struct {
	Admins    []string
	MongoDB   *MongoDBConfig
	APIServer *APIServerConfig

	ChainIDBlackList []string `toml:",omitempty" json:",omitempty"`
	TokenIDBlackList []string `toml:",omitempty" json:",omitempty"`

	// extras
	EnableReplaceSwap          bool
	EnablePassBigValueSwap     bool
	ReplacePlusGasPricePercent uint64            `toml:",omitempty" json:",omitempty"`
	WaitTimeToReplace          int64             `toml:",omitempty" json:",omitempty"` // seconds
	MaxReplaceCount            int               `toml:",omitempty" json:",omitempty"`
	PlusGasPricePercentage     uint64            `toml:",omitempty" json:",omitempty"`
	MaxPlusGasPricePercentage  uint64            `toml:",omitempty" json:",omitempty"`
	MaxGasPriceFluctPercent    uint64            `toml:",omitempty" json:",omitempty"`
	SwapDeadlineOffset         int64             `toml:",omitempty" json:",omitempty"` // seconds
	DefaultGasLimit            map[string]uint64 `toml:",omitempty" json:",omitempty"` // key is chain ID
	FixedGasPrice              map[string]string `toml:",omitempty" json:",omitempty"` // key is chain ID
	MaxGasPrice                map[string]string `toml:",omitempty" json:",omitempty"` // key is chain ID
	NoncePassedConfirmInterval map[string]int64  `toml:",omitempty" json:",omitempty"` // key is chain ID

	DynamicFeeTx map[string]*DynamicFeeTxConfig `toml:",omitempty" json:",omitempty"` // key is chain ID
}

RouterServerConfig only for server

func GetRouterServerConfig

func GetRouterServerConfig() *RouterServerConfig

GetRouterServerConfig get router server config

func (*RouterServerConfig) CheckConfig

func (s *RouterServerConfig) CheckConfig() error

CheckConfig of router server

func (*RouterServerConfig) CheckDynamicFeeTxConfig

func (s *RouterServerConfig) CheckDynamicFeeTxConfig() error

CheckDynamicFeeTxConfig check dynamic fee tx config

func (*RouterServerConfig) CheckExtra

func (s *RouterServerConfig) CheckExtra() error

CheckExtra check extra server config

Jump to

Keyboard shortcuts

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