Documentation ¶
Overview ¶
Package router inits bridges and loads onchain configs.
Index ¶
- Variables
- func AddPausedChainIDs(chainIDs []string)
- func CallOnchainContract(data hexutil.Bytes, blockNumber string) (result []byte, err error)
- func DontPanicInLoading() bool
- func GetAllChainIDs() (chainIDs []*big.Int, err error)
- func GetAllTokenIDs() (tokenIDs []string, err error)
- func GetBridgeByChainID(chainID string) tokens.IBridge
- func GetCachedLatestBlockNumber(chainID string) uint64
- func GetCachedMultichainToken(tokenID, chainID string) (tokenAddr string)
- func GetCachedMultichainTokens(tokenID string) *sync.Map
- func GetChainConfig(chainID *big.Int) (*tokens.ChainConfig, error)
- func GetCustomConfig(chainID *big.Int, key string) (string, error)
- func GetExtraConfig(key string) (string, error)
- func GetFeeConfig(tokenID string, fromChainID, toChainID *big.Int) (*tokens.FeeConfig, error)
- func GetMPCPubkey(mpcAddress string) (pubkey string, err error)
- func GetMPCPublicKey(mpc string) string
- func GetMultichainToken(tokenID string, chainID *big.Int) (tokenAddr string, err error)
- func GetPausedChainIDs() []*big.Int
- func GetRouterMPC(tokenID, chainID string) (string, error)
- func GetSwapConfig(tokenID string, fromChainID, toChainID *big.Int) (*tokens.SwapConfig, error)
- func GetTokenConfig(chainID *big.Int, token string) (tokenCfg *tokens.TokenConfig, err error)
- func GetTokenRouterContract(tokenID, chainID string) (string, error)
- func InitOnchainCustomConfig(chainID *big.Int, tokenID string)
- func InitRouterConfigClients()
- func InitRouterConfigClientsWithArgs(configContract string, gateways []string)
- func InitWebSocketClients(wsServers []string) []*ethclient.Client
- func IsBigValueSwap(swapInfo *tokens.SwapTxInfo) bool
- func IsBlacklistSwap(swapInfo *tokens.SwapTxInfo) bool
- func IsChainIDExist(chainID *big.Int) (exist bool, err error)
- func IsChainIDPaused(chainID string) bool
- func IsNonceSupported(chainID string) bool
- func IsReswapSupported(chainID string) bool
- func IsTokenIDExist(tokenID string) (exist bool, err error)
- func ParseRouterContractConfig(routerContractCfg string) (routerContract, routerVersion string)
- func PrintMultichainTokens()
- func RemovePausedChainIDs(chainIDs []string)
- func SetBridge(chainID string, bridge tokens.IBridge)
- func SetMPCPublicKey(mpc, pubkey string)
- func SetMultichainToken(tokenID, chainID, tokenAddr string)
- func SetMultichainTokens(tokenID string, tokensMap *sync.Map)
- func SetRouterInfo(router, chainID string, routerInfo *SwapRouterInfo)
- func SubscribeRouterConfig(topics []ethcommon.Hash)
- func SubscribeUpdateConfig(callback func() bool)
- type ChainConfigInContract
- type FeeConfigInContract
- type MultichainToken
- type SwapConfigInContract
- type SwapRouterInfo
- type TokenConfigInContract
Constants ¶
This section is empty.
Variables ¶
var ( RouterBridges = new(sync.Map) // key is chainID MultichainTokens = new(sync.Map) // key is tokenID,chainID AllChainIDs []*big.Int // all chainIDs is retrieved only once AllTokenIDs []string // all tokenIDs can be reload MPCPublicKeys = new(sync.Map) // key is mpc address RouterInfos = new(sync.Map) // key is router contract address CachedLatestBlockNumber = new(sync.Map) // key is chainID IsIniting bool IsReloading bool RetryRPCCountInInit = 3 RetryRPCIntervalInInit = 3 * time.Second )
router bridges
Functions ¶
func AddPausedChainIDs ¶
func AddPausedChainIDs(chainIDs []string)
AddPausedChainIDs add paused chainIDs
func CallOnchainContract ¶
CallOnchainContract call onchain contract
func GetBridgeByChainID ¶
GetBridgeByChainID get bridge by chain id
func GetCachedLatestBlockNumber ¶
GetCachedLatestBlockNumber get cached latest block number
func GetCachedMultichainToken ¶
GetCachedMultichainToken get multichain token address by tokenid and chainid
func GetCachedMultichainTokens ¶
GetCachedMultichainTokens get multichain tokens of `tokenid`
func GetChainConfig ¶
func GetChainConfig(chainID *big.Int) (*tokens.ChainConfig, error)
GetChainConfig abi
func GetCustomConfig ¶
GetCustomConfig abi
func GetFeeConfig ¶
GetFeeConfig abi
func GetMPCPubkey ¶
GetMPCPubkey abi
func GetMultichainToken ¶
GetMultichainToken abi
func GetRouterMPC ¶
GetRouterMPC get router mpc on dest chain (to build swapin tx)
func GetSwapConfig ¶
GetSwapConfig abi
func GetTokenConfig ¶
GetTokenConfig abi
func GetTokenRouterContract ¶
GetTokenRouterContract get token router contract
func InitOnchainCustomConfig ¶
InitOnchainCustomConfig init onchain custom config
func InitRouterConfigClients ¶
func InitRouterConfigClients()
InitRouterConfigClients init router config clients
func InitRouterConfigClientsWithArgs ¶
InitRouterConfigClientsWithArgs init standalone
func InitWebSocketClients ¶
InitWebSocketClients init
func IsBigValueSwap ¶
func IsBigValueSwap(swapInfo *tokens.SwapTxInfo) bool
IsBigValueSwap is big value swap
func IsBlacklistSwap ¶
func IsBlacklistSwap(swapInfo *tokens.SwapTxInfo) bool
IsBlacklistSwap is swap blacked
func IsChainIDExist ¶
IsChainIDExist abi
func IsNonceSupported ¶
IsNonceSupported is nonce supported
func IsReswapSupported ¶
IsReswapSupported is reswap supported
func IsTokenIDExist ¶
IsTokenIDExist abi
func ParseRouterContractConfig ¶
ParseRouterContractConfig parse router contract config
func RemovePausedChainIDs ¶
func RemovePausedChainIDs(chainIDs []string)
RemovePausedChainIDs remove paused chainIDs
func SetMPCPublicKey ¶
func SetMPCPublicKey(mpc, pubkey string)
SetMPCPublicKey set router mpc public key
func SetMultichainToken ¶
func SetMultichainToken(tokenID, chainID, tokenAddr string)
SetMultichainToken set multichain token
func SetMultichainTokens ¶
SetMultichainTokens set multichain tokens
func SetRouterInfo ¶
func SetRouterInfo(router, chainID string, routerInfo *SwapRouterInfo)
SetRouterInfo set router info
func SubscribeRouterConfig ¶
SubscribeRouterConfig subscribe router config
func SubscribeUpdateConfig ¶
func SubscribeUpdateConfig(callback func() bool)
SubscribeUpdateConfig subscribe update ID and reload configs
Types ¶
type ChainConfigInContract ¶
type ChainConfigInContract struct { ChainID string BlockChain string RouterContract string Confirmations uint64 InitialHeight uint64 Extra string }
ChainConfigInContract struct
func GetAllChainConfig ¶
func GetAllChainConfig() ([]*ChainConfigInContract, error)
GetAllChainConfig abi
type FeeConfigInContract ¶
type FeeConfigInContract struct { FromChainID *big.Int ToChainID *big.Int MaximumSwapFee *big.Int MinimumSwapFee *big.Int SwapFeeRatePerMillion uint64 }
FeeConfigInContract struct
func GetFeeConfigs ¶
func GetFeeConfigs(tokenID string) ([]FeeConfigInContract, error)
GetFeeConfigs get fee configs by tokenID
type MultichainToken ¶
MultichainToken struct
func GetAllMultichainTokens ¶
func GetAllMultichainTokens(tokenID string) ([]MultichainToken, error)
GetAllMultichainTokens abi
type SwapConfigInContract ¶
type SwapConfigInContract struct { FromChainID *big.Int ToChainID *big.Int MaximumSwap *big.Int MinimumSwap *big.Int BigValueThreshold *big.Int }
SwapConfigInContract struct
func GetSwapConfigs ¶
func GetSwapConfigs(tokenID string) ([]SwapConfigInContract, error)
GetSwapConfigs get swap configs by tokenID
type SwapRouterInfo ¶
type SwapRouterInfo struct { RouterMPC string RouterPDA string `json:",omitempty"` RouterWNative string `json:",omitempty"` RouterSecurity string `json:",omitempty"` }
SwapRouterInfo swap router info
func GetRouterInfo ¶
func GetRouterInfo(router, chainID string) *SwapRouterInfo
GetRouterInfo get router info
func GetTokenRouterInfo ¶
func GetTokenRouterInfo(tokenID, chainID string) (*SwapRouterInfo, error)
GetTokenRouterInfo get token router info
type TokenConfigInContract ¶
type TokenConfigInContract struct { ChainID string Decimals uint8 ContractAddress string ContractVersion uint64 RouterContract string Extra string }
TokenConfigInContract struct
func GetAllMultichainTokenConfig ¶
func GetAllMultichainTokenConfig(tokenID string) ([]*TokenConfigInContract, error)
GetAllMultichainTokenConfig abi