Documentation
¶
Overview ¶
Package api provides RPC and REST API handlers for the DEX VM.
Index ¶
- Variables
- type AddLiquidityArgs
- type AddLiquidityReply
- type CancelOrderArgs
- type CancelOrderReply
- type GetOrderArgs
- type GetOrderReply
- type GetOrderbookArgs
- type GetOrderbookReply
- type GetPoolArgs
- type GetPoolReply
- type GetPoolsArgs
- type GetPoolsReply
- type GetQuoteArgs
- type GetQuoteReply
- type GetStatsArgs
- type GetStatsReply
- type PingArgs
- type PingReply
- type PlaceOrderArgs
- type PlaceOrderReply
- type RemoveLiquidityArgs
- type RemoveLiquidityReply
- type Service
- func (s *Service) AddLiquidity(_ *http.Request, args *AddLiquidityArgs, reply *AddLiquidityReply) error
- func (s *Service) CancelOrder(_ *http.Request, args *CancelOrderArgs, reply *CancelOrderReply) error
- func (s *Service) GetOrder(_ *http.Request, args *GetOrderArgs, reply *GetOrderReply) error
- func (s *Service) GetOrderbook(_ *http.Request, args *GetOrderbookArgs, reply *GetOrderbookReply) error
- func (s *Service) GetPool(_ *http.Request, args *GetPoolArgs, reply *GetPoolReply) error
- func (s *Service) GetPools(_ *http.Request, _ *GetPoolsArgs, reply *GetPoolsReply) error
- func (s *Service) GetQuote(_ *http.Request, args *GetQuoteArgs, reply *GetQuoteReply) error
- func (s *Service) GetStats(_ *http.Request, args *GetStatsArgs, reply *GetStatsReply) error
- func (s *Service) Ping(_ *http.Request, _ *PingArgs, reply *PingReply) error
- func (s *Service) PlaceOrder(_ *http.Request, args *PlaceOrderArgs, reply *PlaceOrderReply) error
- func (s *Service) RemoveLiquidity(_ *http.Request, args *RemoveLiquidityArgs, reply *RemoveLiquidityReply) error
- func (s *Service) Status(_ *http.Request, _ *StatusArgs, reply *StatusReply) error
- func (s *Service) Swap(_ *http.Request, args *SwapArgs, reply *SwapReply) error
- type StatusArgs
- type StatusReply
- type SwapArgs
- type SwapReply
- type VM
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AddLiquidityArgs ¶
type AddLiquidityArgs struct {
PoolID string `json:"poolId"`
Amount0 string `json:"amount0"`
Amount1 string `json:"amount1"`
MinLiquidity string `json:"minLiquidity"`
}
AddLiquidityArgs is the argument for the AddLiquidity API.
type AddLiquidityReply ¶
type AddLiquidityReply struct {
LPTokens string `json:"lpTokens"`
}
AddLiquidityReply is the reply for the AddLiquidity API.
type CancelOrderArgs ¶
CancelOrderArgs is the argument for the CancelOrder API.
type CancelOrderReply ¶
type CancelOrderReply struct {
Success bool `json:"success"`
}
CancelOrderReply is the reply for the CancelOrder API.
type GetOrderArgs ¶
GetOrderArgs is the argument for the GetOrder API.
type GetOrderReply ¶
GetOrderReply is the reply for the GetOrder API.
type GetOrderbookArgs ¶
GetOrderbookArgs is the argument for the GetOrderbook API.
type GetOrderbookReply ¶
type GetOrderbookReply struct {
Symbol string `json:"symbol"`
Bids []*orderbook.PriceLevel `json:"bids"`
Asks []*orderbook.PriceLevel `json:"asks"`
BestBid uint64 `json:"bestBid"`
BestAsk uint64 `json:"bestAsk"`
Spread uint64 `json:"spread"`
MidPrice uint64 `json:"midPrice"`
Timestamp int64 `json:"timestamp"`
}
GetOrderbookReply is the reply for the GetOrderbook API.
type GetPoolArgs ¶
type GetPoolArgs struct {
PoolID string `json:"poolId"`
}
GetPoolArgs is the argument for the GetPool API.
type GetPoolReply ¶
GetPoolReply is the reply for the GetPool API.
type GetPoolsReply ¶
GetPoolsReply is the reply for the GetPools API.
type GetQuoteArgs ¶
type GetQuoteArgs struct {
PoolID string `json:"poolId"`
TokenIn string `json:"tokenIn"`
AmountIn string `json:"amountIn"` // String for big.Int
}
GetQuoteArgs is the argument for the GetQuote API.
type GetQuoteReply ¶
type GetQuoteReply struct {
AmountOut string `json:"amountOut"`
EffectiveRate string `json:"effectiveRate"`
}
GetQuoteReply is the reply for the GetQuote API.
type GetStatsArgs ¶
type GetStatsArgs struct {
Symbol string `json:"symbol"`
}
GetStatsArgs is the argument for the GetStats API.
type GetStatsReply ¶
type GetStatsReply struct {
TotalVolume uint64 `json:"totalVolume"`
TradeCount uint64 `json:"tradeCount"`
LastTradeTime int64 `json:"lastTradeTime"`
}
GetStatsReply is the reply for the GetStats API.
type PingReply ¶
type PingReply struct {
Success bool `json:"success"`
}
PingReply is the reply for the Ping API.
type PlaceOrderArgs ¶
type PlaceOrderArgs struct {
Owner string `json:"owner"` // hex-encoded address
Symbol string `json:"symbol"`
Side string `json:"side"` // "buy" or "sell"
Type string `json:"type"` // "limit", "market", etc.
Price uint64 `json:"price"`
Quantity uint64 `json:"quantity"`
TimeInForce string `json:"timeInForce"` // "GTC", "IOC", "FOK"
PostOnly bool `json:"postOnly"`
ReduceOnly bool `json:"reduceOnly"`
}
PlaceOrderArgs is the argument for the PlaceOrder API.
type PlaceOrderReply ¶
type PlaceOrderReply struct {
OrderID string `json:"orderId"`
Status string `json:"status"`
FilledQty uint64 `json:"filledQty"`
Trades []*orderbook.Trade `json:"trades"`
}
PlaceOrderReply is the reply for the PlaceOrder API.
type RemoveLiquidityArgs ¶
type RemoveLiquidityArgs struct {
PoolID string `json:"poolId"`
Liquidity string `json:"liquidity"`
MinAmount0 string `json:"minAmount0"`
MinAmount1 string `json:"minAmount1"`
}
RemoveLiquidityArgs is the argument for the RemoveLiquidity API.
type RemoveLiquidityReply ¶
type RemoveLiquidityReply struct {
Amount0 string `json:"amount0"`
Amount1 string `json:"amount1"`
}
RemoveLiquidityReply is the reply for the RemoveLiquidity API.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the RPC API for the DEX VM.
func (*Service) AddLiquidity ¶
func (s *Service) AddLiquidity(_ *http.Request, args *AddLiquidityArgs, reply *AddLiquidityReply) error
AddLiquidity adds liquidity to a pool.
func (*Service) CancelOrder ¶
func (s *Service) CancelOrder(_ *http.Request, args *CancelOrderArgs, reply *CancelOrderReply) error
CancelOrder cancels an existing order.
func (*Service) GetOrder ¶
func (s *Service) GetOrder(_ *http.Request, args *GetOrderArgs, reply *GetOrderReply) error
GetOrder returns an order by ID.
func (*Service) GetOrderbook ¶
func (s *Service) GetOrderbook(_ *http.Request, args *GetOrderbookArgs, reply *GetOrderbookReply) error
GetOrderbook returns the current orderbook for a symbol.
func (*Service) GetPool ¶
func (s *Service) GetPool(_ *http.Request, args *GetPoolArgs, reply *GetPoolReply) error
GetPool returns a specific liquidity pool.
func (*Service) GetPools ¶
func (s *Service) GetPools(_ *http.Request, _ *GetPoolsArgs, reply *GetPoolsReply) error
GetPools returns all liquidity pools.
func (*Service) GetQuote ¶
func (s *Service) GetQuote(_ *http.Request, args *GetQuoteArgs, reply *GetQuoteReply) error
GetQuote returns a swap quote.
func (*Service) GetStats ¶
func (s *Service) GetStats(_ *http.Request, args *GetStatsArgs, reply *GetStatsReply) error
GetStats returns trading statistics for a symbol.
func (*Service) PlaceOrder ¶
func (s *Service) PlaceOrder(_ *http.Request, args *PlaceOrderArgs, reply *PlaceOrderReply) error
PlaceOrder places a new order on the orderbook.
func (*Service) RemoveLiquidity ¶
func (s *Service) RemoveLiquidity(_ *http.Request, args *RemoveLiquidityArgs, reply *RemoveLiquidityReply) error
RemoveLiquidity removes liquidity from a pool.
func (*Service) Status ¶
func (s *Service) Status(_ *http.Request, _ *StatusArgs, reply *StatusReply) error
Status returns the DEX status.
type StatusReply ¶
type StatusReply struct {
Bootstrapped bool `json:"bootstrapped"`
Version string `json:"version"`
Uptime int64 `json:"uptime"`
}
StatusReply is the reply for the Status API.
type SwapArgs ¶
type SwapArgs struct {
PoolID string `json:"poolId"`
TokenIn string `json:"tokenIn"`
AmountIn string `json:"amountIn"`
MinAmountOut string `json:"minAmountOut"`
}
SwapArgs is the argument for the Swap API.