Documentation ¶
Index ¶
- Constants
- func CheckAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func CheckJwtAuthByCookie(c echo.Context) error
- func CommonHandler(params Param, fn func(Param) (interface{}, error)) echo.HandlerFunc
- func ErrorHandler(err error, c echo.Context)
- func GenericHTTPCollector() echo.MiddlewareFunc
- func GetJwtAuth(param Param) (interface{}, error)
- func GetOrderFromPalceOrderReq(params *PlaceOrderReq) (*model.Order, error)
- func InitMaiApiContext(next echo.HandlerFunc) echo.HandlerFunc
- func JwtAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func MaiAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func RecoverHandler(next echo.HandlerFunc) echo.HandlerFunc
- type ApiError
- func AddressNotInWhiteListError() *ApiError
- func AuthError(desc string, err error) *ApiError
- func BadSignatureError() *ApiError
- func BindError(err error) *ApiError
- func BrokerAddressError(address string) *ApiError
- func ChainIDError(chainID int64) *ApiError
- func CloseOnlyError() *ApiError
- func ContractSettledError() *ApiError
- func EchoHTTPError(err *echo.HTTPError) *ApiError
- func GasBalanceError() *ApiError
- func InsufficientAllowanceError(token string, need, has decimal.Decimal) *ApiError
- func InsufficientBalanceError() *ApiError
- func InternalError(err error) *ApiError
- func InvalidExpiresError() *ApiError
- func InvalidOrderTypeError() *ApiError
- func InvalidPriceAmountError(desc string) *ApiError
- func MaxOrderNumReachError() *ApiError
- func OrderAuthError(id string) *ApiError
- func OrderExpired() *ApiError
- func OrderHashExistError(orderHash string) *ApiError
- func OrderIDNotExistError(id string) *ApiError
- func PerpetualNotFoundError(perpetual string, index int64) *ApiError
- func RateLimitError(desc string, err error) *ApiError
- func ValidationError(message string) *ApiError
- func ValidatorError(errors validator.ValidationErrors) *ApiError
- type BaseReq
- type BaseResp
- type CancelAllOrdersReq
- type CancelOrderReq
- type GetBrokerRelayReq
- type GetBrokerRelayResp
- type GetPerpetualReq
- type GetPerpetualResp
- type MaiApiContext
- type Param
- type PlaceOrderReq
- type PlaceOrderResp
- type QueryOrderReq
- type QueryOrdersByOrderHashsReq
- type QueryOrdersResp
- type QuerySingleOrderReq
- type QuerySingleOrderResp
- type Response
- type Server
- func (s *Server) CancelAllOrders(p Param) (interface{}, error)
- func (s *Server) CancelOrder(p Param) (interface{}, error)
- func (s *Server) GetBrokerRelay(p Param) (interface{}, error)
- func (s *Server) GetOrderByOrderHash(p Param) (interface{}, error)
- func (s *Server) GetOrders(p Param) (interface{}, error)
- func (s *Server) GetOrdersByOrderHashs(p Param) (interface{}, error)
- func (s *Server) GetPerpetual(p Param) (interface{}, error)
- func (s *Server) PlaceOrder(p Param) (interface{}, error)
- func (s *Server) Start() error
Constants ¶
View Source
const ( // MinOrderExpiration and MaxOrderExpiration represents the valid range of order expiration time; MinOrderExpiration = time.Hour * 24 MaxOrderExpiration = time.Hour * 24 * 90 )
View Source
const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"
Variables ¶
This section is empty.
Functions ¶
func CheckAuthMiddleware ¶
func CheckAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func CheckJwtAuthByCookie ¶
func CommonHandler ¶
func CommonHandler(params Param, fn func(Param) (interface{}, error)) echo.HandlerFunc
func ErrorHandler ¶
func GenericHTTPCollector ¶
func GenericHTTPCollector() echo.MiddlewareFunc
GenericHTTPCollector create a new metrics collector with given config
func GetJwtAuth ¶
func GetOrderFromPalceOrderReq ¶
func GetOrderFromPalceOrderReq(params *PlaceOrderReq) (*model.Order, error)
func InitMaiApiContext ¶
func InitMaiApiContext(next echo.HandlerFunc) echo.HandlerFunc
func JwtAuthMiddleware ¶
func JwtAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func MaiAuthMiddleware ¶
func MaiAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func RecoverHandler ¶
func RecoverHandler(next echo.HandlerFunc) echo.HandlerFunc
Types ¶
type ApiError ¶
type ApiError struct { Code int Desc string Params []string // contains filtered or unexported fields }
ApiError represents error occurs in api requests, containing extra error infomation.
func AddressNotInWhiteListError ¶
func AddressNotInWhiteListError() *ApiError
func BadSignatureError ¶
func BadSignatureError() *ApiError
func BrokerAddressError ¶
func ChainIDError ¶
func CloseOnlyError ¶
func CloseOnlyError() *ApiError
func ContractSettledError ¶
func ContractSettledError() *ApiError
func EchoHTTPError ¶
func GasBalanceError ¶
func GasBalanceError() *ApiError
func InsufficientBalanceError ¶
func InsufficientBalanceError() *ApiError
func InternalError ¶
InternalError represents error caused by internal server error
func InvalidExpiresError ¶
func InvalidExpiresError() *ApiError
func InvalidOrderTypeError ¶
func InvalidOrderTypeError() *ApiError
func InvalidPriceAmountError ¶
func MaxOrderNumReachError ¶
func MaxOrderNumReachError() *ApiError
func OrderAuthError ¶
func OrderExpired ¶
func OrderExpired() *ApiError
func OrderHashExistError ¶
func OrderIDNotExistError ¶
func PerpetualNotFoundError ¶
PerpetualNotFoundError represents error caused by not existe market contract
func RateLimitError ¶
func ValidationError ¶
ValidationError represents error caused by validation failure
func ValidatorError ¶
func ValidatorError(errors validator.ValidationErrors) *ApiError
type BaseReq ¶
type BaseReq struct {
Address string `json:"address" query:"address"`
}
BaseReq represents a basic request data containing wallet addresses from which the request is sent
func (*BaseReq) GetAddress ¶
func (*BaseReq) SetAddress ¶
type BaseResp ¶
BaseResp represents a basic response data containing status and description to indicates the executing result of an api request
type CancelAllOrdersReq ¶
type CancelAllOrdersReq struct {
BaseReq
}
type CancelOrderReq ¶
type GetBrokerRelayReq ¶
type GetBrokerRelayResp ¶
type GetPerpetualReq ¶
type GetPerpetualResp ¶
type MaiApiContext ¶
type MaiApiContext struct { echo.Context // If address is not empty means this user is authenticated. Address string }
MaiApiContext holds user information for API requests
type PlaceOrderReq ¶
type PlaceOrderReq struct { BaseReq OrderHash string `json:"orderHash" validate:"required"` LiquidityPoolAddress string `json:"liquidityPoolAddress" validate:"required"` PerpetualIndex int64 `json:"perpetualIndex"` BrokerAddress string `json:"brokerAddress" validate:"required"` RelayerAddress string `json:"relayerAddress" validate:"required"` ReferrerAddress string `json:"referrerAddress"` OrderType int `json:"orderType" validate:"required,oneof=0 1 2"` Price string `json:"price" validate:"required"` TriggerPrice string `json:"triggerPrice"` Amount string `json:"amount" validate:"required"` MinTradeAmount string `json:"minTradeAmount" validate:"required"` BrokerFeeLimit int64 `json:"brokerFeeLimit"` Salt int64 `json:"salt" validate:"required"` ExpiresAt int64 `json:"expiresAt" validate:"required"` R string `json:"r" validate:"required"` S string `json:"s" validate:"required"` V string `json:"v" validate:"required"` SignType string `json:"signType" validate:"required"` IsCloseOnly bool `json:"isCloseOnly"` ChainID int64 `json:"chainID" validate:"required"` }
type PlaceOrderResp ¶
type QueryOrderReq ¶
type QueryOrderReq struct { BaseReq LiquidityPoolAddress string `json:"liquidityPoolAddress" query:"liquidityPoolAddress"` PerpetualIndex int64 `json:"perpetualIndex" query:"perpetualIndex"` Status string `json:"status" query:"status"` BeforeOrderHash string `json:"beforeOrderHash" query:"beforeOrderHash"` AfterOrderHash string `json:"afterOrderHash" query:"afterOrderHash"` BeginTime int64 `json:"beginTime" query:"beginTime"` EndTime int64 `json:"endTime" query:"endTime"` Limit int `json:"limit" query:"limit"` }
type QueryOrdersResp ¶
type QuerySingleOrderReq ¶
type QuerySingleOrderResp ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CancelAllOrders ¶
func (*Server) CancelOrder ¶
func (*Server) GetBrokerRelay ¶
func (*Server) GetOrderByOrderHash ¶
func (*Server) GetOrdersByOrderHashs ¶
func (*Server) GetPerpetual ¶
func (*Server) PlaceOrder ¶
Click to show internal directories.
Click to hide internal directories.