Documentation ¶
Index ¶
- Constants
- func IsIntime(l *zap.SugaredLogger, nonce string) bool
- type Authentication
- type Blockchain
- type KNAuthentication
- type Permission
- type Server
- func (s *Server) AllPrices(c *gin.Context)
- func (s *Server) AllPricesVersion(c *gin.Context)
- func (s *Server) AuthData(c *gin.Context)
- func (s *Server) AuthDataVersion(c *gin.Context)
- func (s *Server) Authenticated(c *gin.Context, requiredParams []string, perms []Permission) (url.Values, bool)
- func (s *Server) CancelOrder(c *gin.Context)
- func (s *Server) CancelTargetQtyV2(c *gin.Context)
- func (s *Server) CheckRebalanceQuadraticRequest(rq common.RebalanceQuadraticRequest) error
- func (s *Server) ConfirmPWIEquationV2(c *gin.Context)
- func (s *Server) ConfirmPendingFeedSetting(c *gin.Context)
- func (s *Server) ConfirmRebalanceQuadratic(c *gin.Context)
- func (s *Server) ConfirmStableTokenParams(c *gin.Context)
- func (s *Server) ConfirmTargetQtyV2(c *gin.Context)
- func (s *Server) ConfirmTokenUpdate(c *gin.Context)
- func (s *Server) Deposit(c *gin.Context)
- func (s *Server) EnableRebalance(c *gin.Context)
- func (s *Server) EnableSetrate(c *gin.Context)
- func (s *Server) ExchangeNotification(c *gin.Context)
- func (s *Server) GetActiveTokenByID(c *gin.Context)
- func (s *Server) GetActiveTokens(c *gin.Context)
- func (s *Server) GetActivities(c *gin.Context)
- func (s *Server) GetAddress(c *gin.Context)
- func (s *Server) GetAllFetcherConfiguration(c *gin.Context)
- func (s *Server) GetAllSetting(c *gin.Context)
- func (s *Server) GetBTCData(c *gin.Context)
- func (s *Server) GetExchangeInfo(c *gin.Context)
- func (s *Server) GetExchangesStatus(c *gin.Context)
- func (s *Server) GetFee(c *gin.Context)
- func (s *Server) GetFeedConfiguration(c *gin.Context)
- func (s *Server) GetFeedSetting(c *gin.Context)
- func (s *Server) GetGoldData(c *gin.Context)
- func (s *Server) GetInternalTokens(c *gin.Context)
- func (s *Server) GetMinDeposit(c *gin.Context)
- func (s *Server) GetNotifications(c *gin.Context)
- func (s *Server) GetPWIEquationV2(c *gin.Context)
- func (s *Server) GetPendingFeedSetting(c *gin.Context)
- func (s *Server) GetPendingPWIEquationV2(c *gin.Context)
- func (s *Server) GetPendingRebalanceQuadratic(c *gin.Context)
- func (s *Server) GetPendingStableTokenParams(c *gin.Context)
- func (s *Server) GetPendingTargetQtyV2(c *gin.Context)
- func (s *Server) GetPendingTokenUpdates(c *gin.Context)
- func (s *Server) GetRate(c *gin.Context)
- func (s *Server) GetRates(c *gin.Context)
- func (s *Server) GetRebalanceQuadratic(c *gin.Context)
- func (s *Server) GetRebalanceStatus(c *gin.Context)
- func (s *Server) GetSetrateStatus(c *gin.Context)
- func (s *Server) GetStableTokenParams(c *gin.Context)
- func (s *Server) GetTargetQtyV2(c *gin.Context)
- func (s *Server) GetTimeServer(c *gin.Context)
- func (s *Server) GetTokenByAddress(c *gin.Context)
- func (s *Server) GetTradeHistory(c *gin.Context)
- func (s *Server) GetUSDData(c *gin.Context)
- func (s *Server) HoldRebalance(c *gin.Context)
- func (s *Server) HoldSetrate(c *gin.Context)
- func (s *Server) ImmediatePendingActivities(c *gin.Context)
- func (s *Server) Metrics(c *gin.Context)
- func (s *Server) Price(c *gin.Context)
- func (s *Server) ReadyToServe(c *gin.Context)
- func (s *Server) RejectPWIEquationV2(c *gin.Context)
- func (s *Server) RejectPendingFeedSetting(c *gin.Context)
- func (s *Server) RejectRebalanceQuadratic(c *gin.Context)
- func (s *Server) RejectStableTokenParams(c *gin.Context)
- func (s *Server) RejectTokenUpdate(c *gin.Context)
- func (s *Server) Run()
- func (s *Server) SetFeedSetting(c *gin.Context)
- func (s *Server) SetPWIEquationV2(c *gin.Context)
- func (s *Server) SetRate(c *gin.Context)
- func (s *Server) SetRebalanceQuadratic(c *gin.Context)
- func (s *Server) SetStableTokenParams(c *gin.Context)
- func (s *Server) SetTargetQtyV2(c *gin.Context)
- func (s *Server) SetTokenUpdate(c *gin.Context)
- func (s *Server) StopFetcher(c *gin.Context)
- func (s *Server) StoreMetrics(c *gin.Context)
- func (s *Server) TokenSettings(c *gin.Context)
- func (s *Server) Trade(c *gin.Context)
- func (s *Server) UpdateDepositAddress(c *gin.Context)
- func (s *Server) UpdateExchangeFee(c *gin.Context)
- func (s *Server) UpdateExchangeInfo(c *gin.Context)
- func (s *Server) UpdateExchangeMinDeposit(c *gin.Context)
- func (s *Server) UpdateExchangeStatus(c *gin.Context)
- func (s *Server) UpdateFeedConfiguration(c *gin.Context)
- func (s *Server) UpdateFetcherConfiguration(c *gin.Context)
- func (s *Server) ValidateTimeInput(c *gin.Context) (uint64, uint64, bool)
- func (s *Server) Withdraw(c *gin.Context)
- type Setting
Constants ¶
const (
ETHID = "ETH"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Authentication ¶ added in v0.1.1
type Authentication interface {
GetPermission(signed string, message string) []Permission
}
Authentication is the authentication layer of HTTP APIs.
type Blockchain ¶ added in v0.1.1
type Blockchain interface { LoadAndSetTokenIndices() error CheckTokenIndices(ethereum.Address) error GetPricingOPAddress() ethereum.Address GetDepositOPAddress() ethereum.Address GetIntermediatorOPAddress() ethereum.Address ListedTokens() []ethereum.Address }
Blockchain is used in http server as the caller to blockchain for information. Currently it is used for smart contract token's indice query.
type KNAuthentication ¶ added in v0.1.1
type KNAuthentication struct { KNSecret string `json:"kn_secret"` KNReadOnly string `json:"kn_readonly"` KNConfiguration string `json:"kn_configuration"` KNConfirmConf string `json:"kn_confirm_configuration"` }
func NewKNAuthentication ¶ added in v0.1.2
func NewKNAuthentication(secret, readOnly, configuration, confirm string) KNAuthentication
NewKNAuthentication ...
func (KNAuthentication) GetPermission ¶ added in v0.1.1
func (auth KNAuthentication) GetPermission(signed string, message string) []Permission
func (KNAuthentication) KNSign ¶ added in v0.1.1
func (auth KNAuthentication) KNSign(msg string) string
type Permission ¶ added in v0.1.1
type Permission int
const ( ReadOnlyPermission Permission = iota // can only read data RebalancePermission // can do everything except configure setting ConfigurePermission // can read data and configure setting, cannot set rates, deposit, withdraw, trade, cancel activities ConfirmConfPermission // can read data and confirm configuration proposal )
type Server ¶ added in v0.1.1
type Server struct {
// contains filtered or unexported fields
}
Server object
func NewHTTPServer ¶
func NewHTTPServer( app reserve.Data, core reserve.Core, metric metric.Storage, bindAddr string, enableAuth bool, profilerPrefix string, authEngine Authentication, env string, bc Blockchain, setting Setting) *Server
NewHTTPServer create new server instance
func (*Server) AllPricesVersion ¶ added in v0.1.1
AllPricesVersion return current version all price
func (*Server) AuthData ¶ added in v0.1.1
AuthData return authenticated data include: reserve balance on blockchain reserve balance on centralized exchanges pending activities (set rates, buy, sell, deposit, withdraw)
func (*Server) AuthDataVersion ¶ added in v0.1.1
AuthDataVersion return current version of auth data
func (*Server) Authenticated ¶ added in v0.1.1
func (s *Server) Authenticated(c *gin.Context, requiredParams []string, perms []Permission) (url.Values, bool)
Authenticated signed message (message = url encoded both query params and post params, keys are sorted) in "signed" header using HMAC512 params must contain "nonce" which is the unixtime in millisecond. The nonce will be invalid if it differs from server time more than 10s
func (*Server) CancelOrder ¶ added in v0.1.1
CancelOrder cancel an open order on exchanges
func (*Server) CancelTargetQtyV2 ¶ added in v0.1.1
CancelTargetQtyV2 cancel update target quantity request
func (*Server) CheckRebalanceQuadraticRequest ¶ added in v0.1.1
func (s *Server) CheckRebalanceQuadraticRequest(rq common.RebalanceQuadraticRequest) error
CheckRebalanceQuadraticRequest check if request data is valid rq (requested data) follow format map["tokenID"]{"a": float64, "b": float64, "c": float64}
func (*Server) ConfirmPWIEquationV2 ¶ added in v0.1.1
ConfirmPWIEquationV2 accepts the pending PWI equations and remove it from pending bucket.
func (*Server) ConfirmPendingFeedSetting ¶ added in v0.1.2
func (*Server) ConfirmRebalanceQuadratic ¶ added in v0.1.1
ConfirmRebalanceQuadratic confirm configuration for current pending config for rebalance quadratic equation
func (*Server) ConfirmStableTokenParams ¶ added in v0.1.1
ConfirmStableTokenParams confirm change to stable token params
func (*Server) ConfirmTargetQtyV2 ¶ added in v0.1.1
ConfirmTargetQtyV2 confirm change target quantity
func (*Server) ConfirmTokenUpdate ¶ added in v0.1.1
func (*Server) EnableRebalance ¶ added in v0.1.1
EnableRebalance enable rebalance request
func (*Server) EnableSetrate ¶ added in v0.1.1
EnableSetrate turn set rate configuration to enabled
func (*Server) ExchangeNotification ¶ added in v0.1.1
ExchangeNotification get exchange notification config
func (*Server) GetActiveTokenByID ¶ added in v0.1.1
func (*Server) GetActiveTokens ¶ added in v0.1.1
func (*Server) GetActivities ¶ added in v0.1.1
GetActivities return all activities record in a time frame
func (*Server) GetAddress ¶ added in v0.1.1
func (*Server) GetAllFetcherConfiguration ¶ added in v0.1.1
GetAllFetcherConfiguration returns all fetcher config
func (*Server) GetAllSetting ¶ added in v0.1.1
func (*Server) GetBTCData ¶ added in v0.1.1
func (*Server) GetExchangeInfo ¶ added in v0.1.1
GetExchangeInfo return exchange info of one exchange if it is given exchangeID otherwise return all exchanges info
func (*Server) GetExchangesStatus ¶ added in v0.1.1
GetExchangesStatus return exchange status (enabled, disabled) analytics component will only request for enabled exchanges
func (*Server) GetFeedConfiguration ¶ added in v0.1.1
func (*Server) GetFeedSetting ¶ added in v0.1.2
func (*Server) GetGoldData ¶ added in v0.1.1
func (*Server) GetInternalTokens ¶ added in v0.1.1
func (*Server) GetMinDeposit ¶ added in v0.1.1
GetMinDeposit return min deposit config of centralized echanges
func (*Server) GetNotifications ¶ added in v0.1.1
GetNotifications get notifications
func (*Server) GetPWIEquationV2 ¶ added in v0.1.1
GetPWIEquationV2 returns the current PWI equations.
func (*Server) GetPendingFeedSetting ¶ added in v0.1.2
func (*Server) GetPendingPWIEquationV2 ¶ added in v0.1.1
GetPendingPWIEquationV2 returns the pending PWI equations.
func (*Server) GetPendingRebalanceQuadratic ¶ added in v0.1.1
GetPendingRebalanceQuadratic return currently pending config for rebalance quadratic equation if there is no pending equation return success false
func (*Server) GetPendingStableTokenParams ¶ added in v0.1.1
GetPendingStableTokenParams return pending change stable token params
func (*Server) GetPendingTargetQtyV2 ¶ added in v0.1.1
GetPendingTargetQtyV2 get pending change target quantity
func (*Server) GetPendingTokenUpdates ¶ added in v0.1.1
func (*Server) GetRebalanceQuadratic ¶ added in v0.1.1
GetRebalanceQuadratic return current confirmed rebalance quadratic equation
func (*Server) GetRebalanceStatus ¶ added in v0.1.1
GetRebalanceStatus return rebalance configuration status (enabled, disabled)
func (*Server) GetSetrateStatus ¶ added in v0.1.1
GetSetrateStatus return set rate status configuration (enabled, disabled)
func (*Server) GetStableTokenParams ¶ added in v0.1.1
GetStableTokenParams return stable token params
func (*Server) GetTargetQtyV2 ¶ added in v0.1.1
GetTargetQtyV2 return target quantity with v2 format
func (*Server) GetTimeServer ¶ added in v0.1.1
GetTimeServer return current time server
func (*Server) GetTokenByAddress ¶ added in v0.1.1
func (*Server) GetTradeHistory ¶ added in v0.1.1
GetTradeHistory return trade history in centralized exchanges
func (*Server) GetUSDData ¶ added in v0.1.1
func (*Server) HoldRebalance ¶ added in v0.1.1
HoldRebalance disable rebalance - notify analytics to stop sending rebalance request
func (*Server) HoldSetrate ¶ added in v0.1.1
HoldSetrate turn setrate config into disabled
func (*Server) ImmediatePendingActivities ¶ added in v0.1.1
ImmediatePendingActivities return current pending activities
func (*Server) ReadyToServe ¶ added in v0.1.1
func (*Server) RejectPWIEquationV2 ¶ added in v0.1.1
RejectPWIEquationV2 rejects the PWI equations request and removes it from pending storage.
func (*Server) RejectPendingFeedSetting ¶ added in v0.1.2
func (*Server) RejectRebalanceQuadratic ¶ added in v0.1.1
RejectRebalanceQuadratic reject pending configuration for rebalance quadratic function
func (*Server) RejectStableTokenParams ¶ added in v0.1.1
RejectStableTokenParams reject request changes stable token params
func (*Server) RejectTokenUpdate ¶ added in v0.1.1
func (*Server) SetFeedSetting ¶ added in v0.1.2
SetFeedSetting set BaseVolatilitySpread for feed configuration
func (*Server) SetPWIEquationV2 ¶ added in v0.1.1
SetPWIEquationV2 stores the given PWI equations to pending for later evaluation.
func (*Server) SetRebalanceQuadratic ¶ added in v0.1.1
SetRebalanceQuadratic set pending rebalance quadratic equation input data follow json: {"data":{"KNC": {"a": 0.7, "b": 1.2, "c": 1.3}}}
func (*Server) SetStableTokenParams ¶ added in v0.1.1
SetStableTokenParams set stable token params
func (*Server) SetTargetQtyV2 ¶ added in v0.1.1
SetTargetQtyV2 set token target quantity version 2
func (*Server) SetTokenUpdate ¶ added in v0.1.1
SetTokenUpdate will pre-process the token request and put into pending token request It will not apply any change to DB if the request is not as dictated in documentation. Newer request will append if the tokenID is not avail in pending, and overwrite otherwise
func (*Server) StopFetcher ¶ added in v0.1.1
StopFetcher request to stop fetcher
func (*Server) StoreMetrics ¶ added in v0.1.1
StoreMetrics store token metrics
func (*Server) TokenSettings ¶ added in v0.1.1
func (*Server) UpdateDepositAddress ¶ added in v0.1.1
func (*Server) UpdateExchangeFee ¶ added in v0.1.1
func (*Server) UpdateExchangeInfo ¶ added in v0.1.1
func (*Server) UpdateExchangeMinDeposit ¶ added in v0.1.1
func (*Server) UpdateExchangeStatus ¶ added in v0.1.1
UpdateExchangeStatus update exchange status (enable, disable)
func (*Server) UpdateFeedConfiguration ¶ added in v0.1.1
func (*Server) UpdateFetcherConfiguration ¶ added in v0.1.1
UpdateFetcherConfiguration update btc fetcher configuration and return new configuration
func (*Server) ValidateTimeInput ¶ added in v0.1.1
ValidateTimeInput validate from-to time value
type Setting ¶ added in v0.1.1
type Setting interface { GetInternalTokenByID(tokenID string) (common.Token, error) GetActiveTokenByID(tokenID string) (common.Token, error) GetTokenByID(tokenID string) (common.Token, error) GetInternalTokens() ([]common.Token, error) GetAllTokens() ([]common.Token, error) NewTokenPairFromID(base, quote string) (common.TokenPair, error) GetFee(ex settings.ExchangeName) (common.ExchangeFees, error) UpdateFee(ex settings.ExchangeName, data common.ExchangeFees, timestamp uint64) error GetMinDeposit(ex settings.ExchangeName) (common.ExchangesMinDeposit, error) UpdateMinDeposit(ex settings.ExchangeName, minDeposit common.ExchangesMinDeposit, timestamp uint64) error GetDepositAddresses(ex settings.ExchangeName) (common.ExchangeAddresses, error) UpdateDepositAddress(ex settings.ExchangeName, addrs common.ExchangeAddresses, timestamp uint64) error GetExchangeInfo(ex settings.ExchangeName) (common.ExchangeInfo, error) UpdateExchangeInfo(ex settings.ExchangeName, exInfo common.ExchangeInfo, timestamp uint64) error GetExchangeStatus() (common.ExchangesStatus, error) UpdateExchangeStatus(data common.ExchangesStatus) error UpdatePendingTokenUpdates(map[string]common.TokenUpdate) error ApplyTokenWithExchangeSetting([]common.Token, map[settings.ExchangeName]*common.ExchangeSetting, uint64) error GetPendingTokenUpdates() (map[string]common.TokenUpdate, error) RemovePendingTokenUpdates() error GetAllAddresses() (map[string]interface{}, error) GetTokenVersion() (uint64, error) GetExchangeVersion() (uint64, error) GetActiveTokens() ([]common.Token, error) GetTokenByAddress(ethereum.Address) (common.Token, error) GetAddress(settings.AddressName) (ethereum.Address, error) }