Documentation
¶
Index ¶
- Variables
- func AddressNameValues() map[string]AddressName
- func ExchangeTypeValues() map[string]ExchangeName
- func RunningExchanges() []string
- type AddressName
- type AddressSetting
- type ExchangeName
- type ExchangeSetting
- type ExchangeStorage
- type SettingOption
- func WithHandleEmptyDepositAddress(data map[common.ExchangeID]common.ExchangeAddresses) SettingOption
- func WithHandleEmptyExchangeInfo() SettingOption
- func WithHandleEmptyFee(feeConfig map[string]common.ExchangeFees) SettingOption
- func WithHandleEmptyMinDeposit(data map[string]common.ExchangesMinDeposit) SettingOption
- func WithHandleEmptyToken(data map[string]common.Token) SettingOption
- type Settings
- func (s *Settings) ApplyTokenWithExchangeSetting(tokens []common.Token, exSetting map[ExchangeName]*common.ExchangeSetting, ...) error
- func (s *Settings) ETHToken() common.Token
- func (s *Settings) GetActiveTokenByAddress(addr ethereum.Address) (common.Token, error)
- func (s *Settings) GetActiveTokenByID(id string) (common.Token, error)
- func (s *Settings) GetActiveTokens() ([]common.Token, error)
- func (s *Settings) GetAddress(name AddressName) (ethereum.Address, error)
- func (s *Settings) GetAllAddresses() (map[string]interface{}, error)
- func (s *Settings) GetAllTokens() ([]common.Token, error)
- func (s *Settings) GetDepositAddresses(ex ExchangeName) (common.ExchangeAddresses, error)
- func (s *Settings) GetExchangeInfo(ex ExchangeName) (common.ExchangeInfo, error)
- func (s *Settings) GetExchangeNotifications() (common.ExchangeNotifications, error)
- func (s *Settings) GetExchangeStatus() (common.ExchangesStatus, error)
- func (s *Settings) GetExchangeVersion() (uint64, error)
- func (s *Settings) GetExternalTokenByAddress(addr ethereum.Address) (common.Token, error)
- func (s *Settings) GetExternalTokenByID(id string) (common.Token, error)
- func (s *Settings) GetExternalTokens() ([]common.Token, error)
- func (s *Settings) GetFee(ex ExchangeName) (common.ExchangeFees, error)
- func (s *Settings) GetInternalTokenByAddress(addr ethereum.Address) (common.Token, error)
- func (s *Settings) GetInternalTokenByID(id string) (common.Token, error)
- func (s *Settings) GetInternalTokens() ([]common.Token, error)
- func (s *Settings) GetMinDeposit(ex ExchangeName) (common.ExchangesMinDeposit, error)
- func (s *Settings) GetPendingTokenUpdates() (map[string]common.TokenUpdate, error)
- func (s *Settings) GetTokenByAddress(addr ethereum.Address) (common.Token, error)
- func (s *Settings) GetTokenByID(id string) (common.Token, error)
- func (s *Settings) GetTokenVersion() (uint64, error)
- func (s *Settings) MustCreateTokenPair(base, quote string) common.TokenPair
- func (s *Settings) NewExchangeInfo(exName ExchangeName) (common.ExchangeInfo, error)
- func (s *Settings) NewTokenPairFromID(base, quote string) (common.TokenPair, error)
- func (s *Settings) RemovePendingTokenUpdates() error
- func (s *Settings) UpdateDepositAddress(exName ExchangeName, addrs common.ExchangeAddresses, timestamp uint64) error
- func (s *Settings) UpdateExchangeInfo(exName ExchangeName, exInfo common.ExchangeInfo, timestamp uint64) error
- func (s *Settings) UpdateExchangeNotification(exchange, action, tokenPair string, fromTime, toTime uint64, isWarning bool, ...) error
- func (s *Settings) UpdateExchangeStatus(exStatus common.ExchangesStatus) error
- func (s *Settings) UpdateFee(exName ExchangeName, exFee common.ExchangeFees, timestamp uint64) error
- func (s *Settings) UpdateMinDeposit(exName ExchangeName, minDeposit common.ExchangesMinDeposit, timestamp uint64) error
- func (s *Settings) UpdatePendingTokenUpdates(tokenUpdates map[string]common.TokenUpdate) error
- func (s *Settings) UpdateToken(t common.Token, timestamp uint64) error
- type TokenSetting
- type TokenStorage
Constants ¶
This section is empty.
Variables ¶
var ErrExchangeRecordNotFound = errors.New("exchange record not found")
ErrExchangeRecordNotFound will be return on empty db query
var ( // ErrNoAddr error cannot find the address ErrNoAddr = errors.New("cannot find the address") )
var ErrTokenNotFound = errors.New("token not found")
ErrTokenNotFound is the error returned for get operation where the token is not found in database.
Functions ¶
func AddressNameValues ¶
func AddressNameValues() map[string]AddressName
AddressNameValues returns the mapping of the string presentation of address name and its value.
func ExchangeTypeValues ¶
func ExchangeTypeValues() map[string]ExchangeName
ExchangeTypeValues return exchange Name value config
func RunningExchanges ¶
func RunningExchanges() []string
RunningExchanges get the exchangeEnvironment params and return the list of exchanges ID for the current run It returns empty string slice if the ENV is empty string or not found DO NOT CALL this once httpserver has ran.
Types ¶
type AddressName ¶
type AddressName int
AddressName is the name of ethereum address used in core.
const ( //Reserve is the enumerated key for reserve Reserve AddressName = iota //reserve // Proxy address // as we used to call it network // we keep its string name as is so other component won't need to change Proxy //network //Wrapper is the enumberated key for wrapper Wrapper //wrapper //Pricing is the enumberated key for pricing Pricing //pricing )
func (AddressName) String ¶
func (i AddressName) String() string
type AddressSetting ¶
type AddressSetting struct {
Addresses map[AddressName]ethereum.Address
}
AddressSetting type defines component to handle all address setting in core. It contains the storage interface used to query addresses.
func NewAddressSetting ¶
func NewAddressSetting(data common.AddressConfig) *AddressSetting
NewAddressSetting return an implementation of Address Setting
func (*AddressSetting) GetAddress ¶
func (addrSetting *AddressSetting) GetAddress(name AddressName) (ethereum.Address, error)
GetAddress return address from address name
type ExchangeName ¶
type ExchangeName int
ExchangeName is the name of exchanges of which core will use to rebalance.
const ( //Binance is the enumerated key for binance Binance ExchangeName = iota //binance //Bittrex is the enumerated key for bittrex (deprecated) Bittrex //bittrex //Huobi is the enumerated key for huobi Huobi //huobi //StableExchange is the enumerated key for stable_exchange StableExchange //stable_exchange )
func (ExchangeName) String ¶
func (i ExchangeName) String() string
type ExchangeSetting ¶
type ExchangeSetting struct {
Storage ExchangeStorage
}
ExchangeSetting is the struct to implement exchange related setting
func NewExchangeSetting ¶
func NewExchangeSetting(exchangeStorage ExchangeStorage) (*ExchangeSetting, error)
NewExchangeSetting return a new exchange setting
type ExchangeStorage ¶
type ExchangeStorage interface { // GetFee returns a map[tokenID]exchangeFees and error if occur // If there is no exchangeFee matched with key param, error is returned as well GetFee(ex ExchangeName) (common.ExchangeFees, error) // StoreFee stores the fee with exchangeName as key into database and return error if occur StoreFee(ex ExchangeName, data common.ExchangeFees, timestamp uint64) error // GetMinDeposit returns a map[tokenID]MinDeposit and error if occur GetMinDeposit(ex ExchangeName) (common.ExchangesMinDeposit, error) // StoreMinDeposit stores the minDeposit with exchangeName as key into database and return error if occur StoreMinDeposit(ex ExchangeName, minDeposit common.ExchangesMinDeposit, timestamp uint64) error // GetDepositAddresses returns a map[tokenID]DepositAddress and error if occur GetDepositAddresses(ex ExchangeName) (common.ExchangeAddresses, error) // StoreDepositAddress stores the depositAddress with exchangeName as key into database and // return error if occur StoreDepositAddress(ex ExchangeName, addrs common.ExchangeAddresses, timestamp uint64) error // GetExchangeInfo returns the an ExchangeInfo Object for each exchange // and error if occur GetExchangeInfo(ex ExchangeName) (common.ExchangeInfo, error) // StoreExchangeInfo store the ExchangeInfo Object using the exchangeName as the key into database // return error if occur StoreExchangeInfo(ex ExchangeName, exInfo common.ExchangeInfo, timestamp uint64) error GetExchangeStatus() (common.ExchangesStatus, error) StoreExchangeStatus(data common.ExchangesStatus) error GetExchangeNotifications() (common.ExchangeNotifications, error) StoreExchangeNotification(exchange, action, tokenPair string, fromTime, toTime uint64, isWarning bool, msg string) error GetExchangeVersion() (uint64, error) }
type SettingOption ¶
type SettingOption func(s *Settings)
SettingOption sets the initialization behavior of the Settings instance.
func WithHandleEmptyDepositAddress ¶
func WithHandleEmptyDepositAddress(data map[common.ExchangeID]common.ExchangeAddresses) SettingOption
WithHandleEmptyDepositAddress will load the MinDeposit setting from fefault file if the DepositAddress database is empty
func WithHandleEmptyExchangeInfo ¶
func WithHandleEmptyExchangeInfo() SettingOption
WithHandleEmptyExchangeInfo will create a map of TokenPairs from token deposit address to an empty ExchangePrecisionLimit it will return error if occur
func WithHandleEmptyFee ¶
func WithHandleEmptyFee(feeConfig map[string]common.ExchangeFees) SettingOption
WithHandleEmptyFee will load the Fee settings from default file if the fee database is empty. It will mutiply the Funding fee value by 2
func WithHandleEmptyMinDeposit ¶
func WithHandleEmptyMinDeposit(data map[string]common.ExchangesMinDeposit) SettingOption
WithHandleEmptyMinDeposit will load the MinDeposit setting from fefault file if the Mindeposit database is empty. It will mutiply the MinDeposit value by 2
func WithHandleEmptyToken ¶
func WithHandleEmptyToken(data map[string]common.Token) SettingOption
WithHandleEmptyToken will load the token settings from default file if the database is empty.
type Settings ¶
type Settings struct { Tokens *TokenSetting Address *AddressSetting Exchange *ExchangeSetting // contains filtered or unexported fields }
Settings contains shared common settings between all components.
func NewSetting ¶
func NewSetting(token *TokenSetting, address *AddressSetting, exchange *ExchangeSetting, options ...SettingOption) (*Settings, error)
NewSetting create setting object from its component, and handle if the setting database is empty returns a pointer to setting object from which all core setting can be read and write to; and error if occurs.
func (*Settings) ApplyTokenWithExchangeSetting ¶
func (s *Settings) ApplyTokenWithExchangeSetting(tokens []common.Token, exSetting map[ExchangeName]*common.ExchangeSetting, timestamp uint64) error
func (*Settings) GetActiveTokenByAddress ¶
func (*Settings) GetActiveTokenByID ¶
func (*Settings) GetAddress ¶
func (s *Settings) GetAddress(name AddressName) (ethereum.Address, error)
GetAddress return address from address name
func (*Settings) GetAllAddresses ¶
GetAllAddresses return all the address setting in cores.
func (*Settings) GetDepositAddresses ¶
func (s *Settings) GetDepositAddresses(ex ExchangeName) (common.ExchangeAddresses, error)
GetDepositAddresses returns a map[tokenID]DepositAddress and error if occur
func (*Settings) GetExchangeInfo ¶
func (s *Settings) GetExchangeInfo(ex ExchangeName) (common.ExchangeInfo, error)
GetExchangeInfor returns the an ExchangeInfo Object for each exchange and error if occur
func (*Settings) GetExchangeNotifications ¶
func (s *Settings) GetExchangeNotifications() (common.ExchangeNotifications, error)
func (*Settings) GetExchangeStatus ¶
func (s *Settings) GetExchangeStatus() (common.ExchangesStatus, error)
func (*Settings) GetExchangeVersion ¶
func (*Settings) GetExternalTokenByAddress ¶
func (*Settings) GetExternalTokenByID ¶
func (*Settings) GetFee ¶
func (s *Settings) GetFee(ex ExchangeName) (common.ExchangeFees, error)
GetFee returns a map[tokenID]exchangeFees and error if occur
func (*Settings) GetInternalTokenByAddress ¶
func (*Settings) GetInternalTokenByID ¶
func (*Settings) GetMinDeposit ¶
func (s *Settings) GetMinDeposit(ex ExchangeName) (common.ExchangesMinDeposit, error)
GetMinDeposit returns a map[tokenID]MinDeposit and error if occur
func (*Settings) GetPendingTokenUpdates ¶
func (s *Settings) GetPendingTokenUpdates() (map[string]common.TokenUpdate, error)
func (*Settings) GetTokenByAddress ¶
func (*Settings) GetTokenVersion ¶
func (*Settings) MustCreateTokenPair ¶
func (*Settings) NewExchangeInfo ¶
func (s *Settings) NewExchangeInfo(exName ExchangeName) (common.ExchangeInfo, error)
NewExchangeInfo return an an ExchangeInfo
func (*Settings) NewTokenPairFromID ¶
func (*Settings) RemovePendingTokenUpdates ¶
func (*Settings) UpdateDepositAddress ¶
func (s *Settings) UpdateDepositAddress(exName ExchangeName, addrs common.ExchangeAddresses, timestamp uint64) error
Update get the deposit Addresses with exchangeName as key, change the desired deposit address then store into database and return error if occur
func (*Settings) UpdateExchangeInfo ¶
func (s *Settings) UpdateExchangeInfo(exName ExchangeName, exInfo common.ExchangeInfo, timestamp uint64) error
UpdateExchangeInfo will merge the new exchange info into current exchange info , the updates exchange info object using exchangeName as key returns error if occur
func (*Settings) UpdateExchangeNotification ¶
func (*Settings) UpdateExchangeStatus ¶
func (s *Settings) UpdateExchangeStatus(exStatus common.ExchangesStatus) error
func (*Settings) UpdateFee ¶
func (s *Settings) UpdateFee(exName ExchangeName, exFee common.ExchangeFees, timestamp uint64) error
UpdateFee will merge the current fee setting to the new fee setting, Any different will be overwriten from new fee to cufrent fee Afterwhich it stores the fee with exchangeName as key into database and return error if occur
func (*Settings) UpdateMinDeposit ¶
func (s *Settings) UpdateMinDeposit(exName ExchangeName, minDeposit common.ExchangesMinDeposit, timestamp uint64) error
UpdateMinDeposit will merge the current min Deposit to the new min Deposit, Any different will be overwriten from new minDeposit to cufrent minDeposit Afterwhich it stores the fee with exchangeName as key into database and return error if occur
func (*Settings) UpdatePendingTokenUpdates ¶
func (s *Settings) UpdatePendingTokenUpdates(tokenUpdates map[string]common.TokenUpdate) error
type TokenSetting ¶
type TokenSetting struct {
Storage TokenStorage
}
TokenSetting is the object to implement token setting interface
func NewTokenSetting ¶
func NewTokenSetting(tokenStorage TokenStorage) (*TokenSetting, error)
NewTokenSetting return a TokenSetting instance
type TokenStorage ¶
type TokenStorage interface { //Add Tokens by ID AddTokenByID(common.Token, uint64) error //Add Tokens by Address AddTokenByAddress(common.Token, uint64) error //Update common UpdateToken(common.Token, uint64) error //Active Tokens (Network Tokens) GetActiveTokens() ([]common.Token, error) GetActiveTokenByID(id string) (common.Token, error) GetActiveTokenByAddress(ethereum.Address) (common.Token, error) //All Tokens (Supported tokens) GetAllTokens() ([]common.Token, error) GetTokenByID(id string) (common.Token, error) GetTokenByAddress(ethereum.Address) (common.Token, error) //Internal Active Tokens GetInternalTokens() ([]common.Token, error) GetInternalTokenByID(id string) (common.Token, error) GetInternalTokenByAddress(ethereum.Address) (common.Token, error) //External Active Tokens GetExternalTokens() ([]common.Token, error) GetExternalTokenByID(id string) (common.Token, error) GetExternalTokenByAddress(ethereum.Address) (common.Token, error) StorePendingTokenUpdates(map[string]common.TokenUpdate) error GetPendingTokenUpdates() (map[string]common.TokenUpdate, error) UpdateTokenWithExchangeSetting(t []common.Token, exSetting map[ExchangeName]*common.ExchangeSetting, availExs []ExchangeName, timestamp uint64) error RemovePendingTokenUpdates() error GetTokenVersion() (uint64, error) }
TokenStorage defines a set of function abstracting the storage interface for Token All key for update and lookup inside the storage must be in lower key