http

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ETHID = "ETH"
)

Variables

This section is empty.

Functions

func IsIntime added in v0.1.1

func IsIntime(l *zap.SugaredLogger, nonce string) bool

IsIntime check if request time is in range of 30s, otherwise the request is invalid

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) AllPrices added in v0.1.1

func (s *Server) AllPrices(c *gin.Context)

AllPrices return all prices of token

func (*Server) AllPricesVersion added in v0.1.1

func (s *Server) AllPricesVersion(c *gin.Context)

AllPricesVersion return current version all price

func (*Server) AuthData added in v0.1.1

func (s *Server) AuthData(c *gin.Context)

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

func (s *Server) AuthDataVersion(c *gin.Context)

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

func (s *Server) CancelOrder(c *gin.Context)

CancelOrder cancel an open order on exchanges

func (*Server) CancelTargetQtyV2 added in v0.1.1

func (s *Server) CancelTargetQtyV2(c *gin.Context)

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

func (s *Server) ConfirmPWIEquationV2(c *gin.Context)

ConfirmPWIEquationV2 accepts the pending PWI equations and remove it from pending bucket.

func (*Server) ConfirmPendingFeedSetting added in v0.1.2

func (s *Server) ConfirmPendingFeedSetting(c *gin.Context)

func (*Server) ConfirmRebalanceQuadratic added in v0.1.1

func (s *Server) ConfirmRebalanceQuadratic(c *gin.Context)

ConfirmRebalanceQuadratic confirm configuration for current pending config for rebalance quadratic equation

func (*Server) ConfirmStableTokenParams added in v0.1.1

func (s *Server) ConfirmStableTokenParams(c *gin.Context)

ConfirmStableTokenParams confirm change to stable token params

func (*Server) ConfirmTargetQtyV2 added in v0.1.1

func (s *Server) ConfirmTargetQtyV2(c *gin.Context)

ConfirmTargetQtyV2 confirm change target quantity

func (*Server) ConfirmTokenUpdate added in v0.1.1

func (s *Server) ConfirmTokenUpdate(c *gin.Context)

func (*Server) Deposit added in v0.1.1

func (s *Server) Deposit(c *gin.Context)

Deposit token to exchange

func (*Server) EnableRebalance added in v0.1.1

func (s *Server) EnableRebalance(c *gin.Context)

EnableRebalance enable rebalance request

func (*Server) EnableSetrate added in v0.1.1

func (s *Server) EnableSetrate(c *gin.Context)

EnableSetrate turn set rate configuration to enabled

func (*Server) ExchangeNotification added in v0.1.1

func (s *Server) ExchangeNotification(c *gin.Context)

ExchangeNotification get exchange notification config

func (*Server) GetActiveTokenByID added in v0.1.1

func (s *Server) GetActiveTokenByID(c *gin.Context)

func (*Server) GetActiveTokens added in v0.1.1

func (s *Server) GetActiveTokens(c *gin.Context)

func (*Server) GetActivities added in v0.1.1

func (s *Server) GetActivities(c *gin.Context)

GetActivities return all activities record in a time frame

func (*Server) GetAddress added in v0.1.1

func (s *Server) GetAddress(c *gin.Context)

func (*Server) GetAllFetcherConfiguration added in v0.1.1

func (s *Server) GetAllFetcherConfiguration(c *gin.Context)

GetAllFetcherConfiguration returns all fetcher config

func (*Server) GetAllSetting added in v0.1.1

func (s *Server) GetAllSetting(c *gin.Context)

func (*Server) GetBTCData added in v0.1.1

func (s *Server) GetBTCData(c *gin.Context)

func (*Server) GetExchangeInfo added in v0.1.1

func (s *Server) GetExchangeInfo(c *gin.Context)

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

func (s *Server) GetExchangesStatus(c *gin.Context)

GetExchangesStatus return exchange status (enabled, disabled) analytics component will only request for enabled exchanges

func (*Server) GetFee added in v0.1.1

func (s *Server) GetFee(c *gin.Context)

GetFee return centralized exchanges fee config

func (*Server) GetFeedConfiguration added in v0.1.1

func (s *Server) GetFeedConfiguration(c *gin.Context)

func (*Server) GetFeedSetting added in v0.1.2

func (s *Server) GetFeedSetting(c *gin.Context)

func (*Server) GetGoldData added in v0.1.1

func (s *Server) GetGoldData(c *gin.Context)

func (*Server) GetInternalTokens added in v0.1.1

func (s *Server) GetInternalTokens(c *gin.Context)

func (*Server) GetMinDeposit added in v0.1.1

func (s *Server) GetMinDeposit(c *gin.Context)

GetMinDeposit return min deposit config of centralized echanges

func (*Server) GetNotifications added in v0.1.1

func (s *Server) GetNotifications(c *gin.Context)

GetNotifications get notifications

func (*Server) GetPWIEquationV2 added in v0.1.1

func (s *Server) GetPWIEquationV2(c *gin.Context)

GetPWIEquationV2 returns the current PWI equations.

func (*Server) GetPendingFeedSetting added in v0.1.2

func (s *Server) GetPendingFeedSetting(c *gin.Context)

func (*Server) GetPendingPWIEquationV2 added in v0.1.1

func (s *Server) GetPendingPWIEquationV2(c *gin.Context)

GetPendingPWIEquationV2 returns the pending PWI equations.

func (*Server) GetPendingRebalanceQuadratic added in v0.1.1

func (s *Server) GetPendingRebalanceQuadratic(c *gin.Context)

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

func (s *Server) GetPendingStableTokenParams(c *gin.Context)

GetPendingStableTokenParams return pending change stable token params

func (*Server) GetPendingTargetQtyV2 added in v0.1.1

func (s *Server) GetPendingTargetQtyV2(c *gin.Context)

GetPendingTargetQtyV2 get pending change target quantity

func (*Server) GetPendingTokenUpdates added in v0.1.1

func (s *Server) GetPendingTokenUpdates(c *gin.Context)

func (*Server) GetRate added in v0.1.1

func (s *Server) GetRate(c *gin.Context)

GetRate return all rates

func (*Server) GetRates added in v0.1.1

func (s *Server) GetRates(c *gin.Context)

GetRates return all rates

func (*Server) GetRebalanceQuadratic added in v0.1.1

func (s *Server) GetRebalanceQuadratic(c *gin.Context)

GetRebalanceQuadratic return current confirmed rebalance quadratic equation

func (*Server) GetRebalanceStatus added in v0.1.1

func (s *Server) GetRebalanceStatus(c *gin.Context)

GetRebalanceStatus return rebalance configuration status (enabled, disabled)

func (*Server) GetSetrateStatus added in v0.1.1

func (s *Server) GetSetrateStatus(c *gin.Context)

GetSetrateStatus return set rate status configuration (enabled, disabled)

func (*Server) GetStableTokenParams added in v0.1.1

func (s *Server) GetStableTokenParams(c *gin.Context)

GetStableTokenParams return stable token params

func (*Server) GetTargetQtyV2 added in v0.1.1

func (s *Server) GetTargetQtyV2(c *gin.Context)

GetTargetQtyV2 return target quantity with v2 format

func (*Server) GetTimeServer added in v0.1.1

func (s *Server) GetTimeServer(c *gin.Context)

GetTimeServer return current time server

func (*Server) GetTokenByAddress added in v0.1.1

func (s *Server) GetTokenByAddress(c *gin.Context)

func (*Server) GetTradeHistory added in v0.1.1

func (s *Server) GetTradeHistory(c *gin.Context)

GetTradeHistory return trade history in centralized exchanges

func (*Server) GetUSDData added in v0.1.1

func (s *Server) GetUSDData(c *gin.Context)

func (*Server) HoldRebalance added in v0.1.1

func (s *Server) HoldRebalance(c *gin.Context)

HoldRebalance disable rebalance - notify analytics to stop sending rebalance request

func (*Server) HoldSetrate added in v0.1.1

func (s *Server) HoldSetrate(c *gin.Context)

HoldSetrate turn setrate config into disabled

func (*Server) ImmediatePendingActivities added in v0.1.1

func (s *Server) ImmediatePendingActivities(c *gin.Context)

ImmediatePendingActivities return current pending activities

func (*Server) Metrics added in v0.1.1

func (s *Server) Metrics(c *gin.Context)

Metrics return metrics

func (*Server) Price added in v0.1.1

func (s *Server) Price(c *gin.Context)

Price return price for a certain pair of token

func (*Server) ReadyToServe added in v0.1.1

func (s *Server) ReadyToServe(c *gin.Context)

func (*Server) RejectPWIEquationV2 added in v0.1.1

func (s *Server) RejectPWIEquationV2(c *gin.Context)

RejectPWIEquationV2 rejects the PWI equations request and removes it from pending storage.

func (*Server) RejectPendingFeedSetting added in v0.1.2

func (s *Server) RejectPendingFeedSetting(c *gin.Context)

func (*Server) RejectRebalanceQuadratic added in v0.1.1

func (s *Server) RejectRebalanceQuadratic(c *gin.Context)

RejectRebalanceQuadratic reject pending configuration for rebalance quadratic function

func (*Server) RejectStableTokenParams added in v0.1.1

func (s *Server) RejectStableTokenParams(c *gin.Context)

RejectStableTokenParams reject request changes stable token params

func (*Server) RejectTokenUpdate added in v0.1.1

func (s *Server) RejectTokenUpdate(c *gin.Context)

func (*Server) Run added in v0.1.1

func (s *Server) Run()

Run the server

func (*Server) SetFeedSetting added in v0.1.2

func (s *Server) SetFeedSetting(c *gin.Context)

SetFeedSetting set BaseVolatilitySpread for feed configuration

func (*Server) SetPWIEquationV2 added in v0.1.1

func (s *Server) SetPWIEquationV2(c *gin.Context)

SetPWIEquationV2 stores the given PWI equations to pending for later evaluation.

func (*Server) SetRate added in v0.1.1

func (s *Server) SetRate(c *gin.Context)

SetRate call set rate token to blockchain

func (*Server) SetRebalanceQuadratic added in v0.1.1

func (s *Server) SetRebalanceQuadratic(c *gin.Context)

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

func (s *Server) SetStableTokenParams(c *gin.Context)

SetStableTokenParams set stable token params

func (*Server) SetTargetQtyV2 added in v0.1.1

func (s *Server) SetTargetQtyV2(c *gin.Context)

SetTargetQtyV2 set token target quantity version 2

func (*Server) SetTokenUpdate added in v0.1.1

func (s *Server) SetTokenUpdate(c *gin.Context)

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

func (s *Server) StopFetcher(c *gin.Context)

StopFetcher request to stop fetcher

func (*Server) StoreMetrics added in v0.1.1

func (s *Server) StoreMetrics(c *gin.Context)

StoreMetrics store token metrics

func (*Server) TokenSettings added in v0.1.1

func (s *Server) TokenSettings(c *gin.Context)

func (*Server) Trade added in v0.1.1

func (s *Server) Trade(c *gin.Context)

Trade do trade action to centralize exchanges

func (*Server) UpdateDepositAddress added in v0.1.1

func (s *Server) UpdateDepositAddress(c *gin.Context)

func (*Server) UpdateExchangeFee added in v0.1.1

func (s *Server) UpdateExchangeFee(c *gin.Context)

func (*Server) UpdateExchangeInfo added in v0.1.1

func (s *Server) UpdateExchangeInfo(c *gin.Context)

func (*Server) UpdateExchangeMinDeposit added in v0.1.1

func (s *Server) UpdateExchangeMinDeposit(c *gin.Context)

func (*Server) UpdateExchangeStatus added in v0.1.1

func (s *Server) UpdateExchangeStatus(c *gin.Context)

UpdateExchangeStatus update exchange status (enable, disable)

func (*Server) UpdateFeedConfiguration added in v0.1.1

func (s *Server) UpdateFeedConfiguration(c *gin.Context)

func (*Server) UpdateFetcherConfiguration added in v0.1.1

func (s *Server) UpdateFetcherConfiguration(c *gin.Context)

UpdateFetcherConfiguration update btc fetcher configuration and return new configuration

func (*Server) ValidateTimeInput added in v0.1.1

func (s *Server) ValidateTimeInput(c *gin.Context) (uint64, uint64, bool)

ValidateTimeInput validate from-to time value

func (*Server) Withdraw added in v0.1.1

func (s *Server) Withdraw(c *gin.Context)

Withdraw withdraw token from exchanges

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)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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