Documentation
¶
Overview ¶
Package api provides RPC and REST API handlers for the DEX VM.
Index ¶
- Variables
- type ADLEngine
- type AddLiquidityArgs
- type AddLiquidityReply
- type CancelOrderArgs
- type CancelOrderReply
- type CommitmentStore
- type GetADLEventsArgs
- type GetADLEventsReply
- type GetADLStatsArgs
- type GetADLStatsReply
- type GetADLStatusArgs
- type GetADLStatusReply
- type GetAccountArgs
- type GetAccountReply
- type GetCommitmentArgs
- type GetCommitmentReply
- type GetCommitmentsArgs
- type GetCommitmentsReply
- type GetFundingRateArgs
- type GetFundingRateReply
- type GetInsuranceFundArgs
- type GetInsuranceFundReply
- type GetMEVStatsArgs
- type GetMEVStatsReply
- type GetMarketArgs
- type GetMarketReply
- type GetMarketsArgs
- type GetMarketsReply
- type GetOrderArgs
- type GetOrderReply
- type GetOrderbookArgs
- type GetOrderbookReply
- type GetPoolArgs
- type GetPoolReply
- type GetPoolsArgs
- type GetPoolsReply
- type GetPositionArgs
- type GetPositionReply
- type GetPositionsArgs
- type GetPositionsReply
- type GetQuoteArgs
- type GetQuoteReply
- type GetStatsArgs
- type GetStatsReply
- type PerpetualsEngine
- 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) GetADLEvents(_ *http.Request, args *GetADLEventsArgs, reply *GetADLEventsReply) error
- func (s *Service) GetADLStats(_ *http.Request, _ *GetADLStatsArgs, reply *GetADLStatsReply) error
- func (s *Service) GetADLStatus(_ *http.Request, args *GetADLStatusArgs, reply *GetADLStatusReply) error
- func (s *Service) GetAccount(_ *http.Request, args *GetAccountArgs, reply *GetAccountReply) error
- func (s *Service) GetCommitment(_ *http.Request, args *GetCommitmentArgs, reply *GetCommitmentReply) error
- func (s *Service) GetCommitments(_ *http.Request, args *GetCommitmentsArgs, reply *GetCommitmentsReply) error
- func (s *Service) GetFundingRate(_ *http.Request, args *GetFundingRateArgs, reply *GetFundingRateReply) error
- func (s *Service) GetInsuranceFund(_ *http.Request, _ *GetInsuranceFundArgs, reply *GetInsuranceFundReply) error
- func (s *Service) GetMEVStats(_ *http.Request, _ *GetMEVStatsArgs, reply *GetMEVStatsReply) error
- func (s *Service) GetMarket(_ *http.Request, args *GetMarketArgs, reply *GetMarketReply) error
- func (s *Service) GetMarkets(_ *http.Request, _ *GetMarketsArgs, reply *GetMarketsReply) 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) GetPosition(_ *http.Request, args *GetPositionArgs, reply *GetPositionReply) error
- func (s *Service) GetPositions(_ *http.Request, args *GetPositionsArgs, reply *GetPositionsReply) 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 ADLEngine ¶ added in v1.22.76
type ADLEngine interface {
GetCandidateCount(symbol string) (longs, shorts int)
Statistics() interface{}
GetEvents(limit int) []interface{}
ShouldTriggerADL(currentFund, targetFund *big.Int) bool
}
ADLEngine interface for auto-deleveraging.
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 CommitmentStore ¶ added in v1.22.76
type CommitmentStore interface {
GetCommitment(hash ids.ID) (interface{}, bool)
GetSenderCommitments(sender ids.ShortID) []interface{}
Statistics() interface{}
}
CommitmentStore interface for MEV protection.
type GetADLEventsArgs ¶ added in v1.22.76
type GetADLEventsArgs struct {
Limit int `json:"limit"`
}
GetADLEventsArgs is the argument for the GetADLEvents API.
type GetADLEventsReply ¶ added in v1.22.76
type GetADLEventsReply struct {
Events []interface{} `json:"events"`
}
GetADLEventsReply is the reply for the GetADLEvents API.
type GetADLStatsArgs ¶ added in v1.22.76
type GetADLStatsArgs struct{}
GetADLStatsArgs is the argument for the GetADLStats API.
type GetADLStatsReply ¶ added in v1.22.76
type GetADLStatsReply struct {
Stats interface{} `json:"stats"`
}
GetADLStatsReply is the reply for the GetADLStats API.
type GetADLStatusArgs ¶ added in v1.22.76
type GetADLStatusArgs struct {
Symbol string `json:"symbol"`
}
GetADLStatusArgs is the argument for the GetADLStatus API.
type GetADLStatusReply ¶ added in v1.22.76
type GetADLStatusReply struct {
LongCandidates int `json:"longCandidates"`
ShortCandidates int `json:"shortCandidates"`
ShouldTrigger bool `json:"shouldTrigger"`
}
GetADLStatusReply is the reply for the GetADLStatus API.
type GetAccountArgs ¶ added in v1.22.76
type GetAccountArgs struct {
TraderID string `json:"traderId"`
}
GetAccountArgs is the argument for the GetAccount API.
type GetAccountReply ¶ added in v1.22.76
type GetAccountReply struct {
Account interface{} `json:"account"`
MarginRatio string `json:"marginRatio"`
}
GetAccountReply is the reply for the GetAccount API.
type GetCommitmentArgs ¶ added in v1.22.76
type GetCommitmentArgs struct {
CommitmentHash string `json:"commitmentHash"`
}
GetCommitmentArgs is the argument for the GetCommitment API.
type GetCommitmentReply ¶ added in v1.22.76
type GetCommitmentReply struct {
Commitment interface{} `json:"commitment"`
Found bool `json:"found"`
}
GetCommitmentReply is the reply for the GetCommitment API.
type GetCommitmentsArgs ¶ added in v1.22.76
type GetCommitmentsArgs struct {
Sender string `json:"sender"`
}
GetCommitmentsArgs is the argument for the GetCommitments API.
type GetCommitmentsReply ¶ added in v1.22.76
type GetCommitmentsReply struct {
Commitments []interface{} `json:"commitments"`
}
GetCommitmentsReply is the reply for the GetCommitments API.
type GetFundingRateArgs ¶ added in v1.22.76
type GetFundingRateArgs struct {
Symbol string `json:"symbol"`
}
GetFundingRateArgs is the argument for the GetFundingRate API.
type GetFundingRateReply ¶ added in v1.22.76
type GetFundingRateReply struct {
FundingRate string `json:"fundingRate"`
NextFundingTime int64 `json:"nextFundingTime"`
}
GetFundingRateReply is the reply for the GetFundingRate API.
type GetInsuranceFundArgs ¶ added in v1.22.76
type GetInsuranceFundArgs struct{}
GetInsuranceFundArgs is the argument for the GetInsuranceFund API.
type GetInsuranceFundReply ¶ added in v1.22.76
type GetInsuranceFundReply struct {
Balance string `json:"balance"`
}
GetInsuranceFundReply is the reply for the GetInsuranceFund API.
type GetMEVStatsArgs ¶ added in v1.22.76
type GetMEVStatsArgs struct{}
GetMEVStatsArgs is the argument for the GetMEVStats API.
type GetMEVStatsReply ¶ added in v1.22.76
type GetMEVStatsReply struct {
Stats interface{} `json:"stats"`
}
GetMEVStatsReply is the reply for the GetMEVStats API.
type GetMarketArgs ¶ added in v1.22.76
type GetMarketArgs struct {
Symbol string `json:"symbol"`
}
GetMarketArgs is the argument for the GetMarket API.
type GetMarketReply ¶ added in v1.22.76
type GetMarketReply struct {
Market interface{} `json:"market"`
}
GetMarketReply is the reply for the GetMarket API.
type GetMarketsArgs ¶ added in v1.22.76
type GetMarketsArgs struct{}
GetMarketsArgs is the argument for the GetMarkets API.
type GetMarketsReply ¶ added in v1.22.76
type GetMarketsReply struct {
Markets []interface{} `json:"markets"`
}
GetMarketsReply is the reply for the GetMarkets 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 GetPositionArgs ¶ added in v1.22.76
GetPositionArgs is the argument for the GetPosition API.
type GetPositionReply ¶ added in v1.22.76
type GetPositionReply struct {
Position interface{} `json:"position"`
}
GetPositionReply is the reply for the GetPosition API.
type GetPositionsArgs ¶ added in v1.22.76
type GetPositionsArgs struct {
TraderID string `json:"traderId"`
}
GetPositionsArgs is the argument for the GetPositions API.
type GetPositionsReply ¶ added in v1.22.76
type GetPositionsReply struct {
Positions []interface{} `json:"positions"`
}
GetPositionsReply is the reply for the GetPositions 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 PerpetualsEngine ¶ added in v1.22.76
type PerpetualsEngine interface {
GetMarket(symbol string) (interface{}, error)
GetAllMarkets() []interface{}
GetAccount(traderID ids.ID) (interface{}, error)
GetPosition(traderID ids.ID, market string) (interface{}, error)
GetAllPositions(traderID ids.ID) ([]interface{}, error)
GetInsuranceFund() *big.Int
GetMarginRatio(traderID ids.ID) (*big.Int, error)
}
PerpetualsEngine interface for perpetuals trading.
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) GetADLEvents ¶ added in v1.22.76
func (s *Service) GetADLEvents(_ *http.Request, args *GetADLEventsArgs, reply *GetADLEventsReply) error
GetADLEvents returns recent ADL events.
func (*Service) GetADLStats ¶ added in v1.22.76
func (s *Service) GetADLStats(_ *http.Request, _ *GetADLStatsArgs, reply *GetADLStatsReply) error
GetADLStats returns ADL engine statistics.
func (*Service) GetADLStatus ¶ added in v1.22.76
func (s *Service) GetADLStatus(_ *http.Request, args *GetADLStatusArgs, reply *GetADLStatusReply) error
GetADLStatus returns ADL status for a symbol.
func (*Service) GetAccount ¶ added in v1.22.76
func (s *Service) GetAccount(_ *http.Request, args *GetAccountArgs, reply *GetAccountReply) error
GetAccount returns a trader's margin account.
func (*Service) GetCommitment ¶ added in v1.22.76
func (s *Service) GetCommitment(_ *http.Request, args *GetCommitmentArgs, reply *GetCommitmentReply) error
GetCommitment returns a commitment by hash.
func (*Service) GetCommitments ¶ added in v1.22.76
func (s *Service) GetCommitments(_ *http.Request, args *GetCommitmentsArgs, reply *GetCommitmentsReply) error
GetCommitments returns all pending commitments for a sender.
func (*Service) GetFundingRate ¶ added in v1.22.76
func (s *Service) GetFundingRate(_ *http.Request, args *GetFundingRateArgs, reply *GetFundingRateReply) error
GetFundingRate returns the funding rate for a perpetual market.
func (*Service) GetInsuranceFund ¶ added in v1.22.76
func (s *Service) GetInsuranceFund(_ *http.Request, _ *GetInsuranceFundArgs, reply *GetInsuranceFundReply) error
GetInsuranceFund returns the insurance fund balance.
func (*Service) GetMEVStats ¶ added in v1.22.76
func (s *Service) GetMEVStats(_ *http.Request, _ *GetMEVStatsArgs, reply *GetMEVStatsReply) error
GetMEVStats returns MEV protection statistics.
func (*Service) GetMarket ¶ added in v1.22.76
func (s *Service) GetMarket(_ *http.Request, args *GetMarketArgs, reply *GetMarketReply) error
GetMarket returns a specific perpetual market.
func (*Service) GetMarkets ¶ added in v1.22.76
func (s *Service) GetMarkets(_ *http.Request, _ *GetMarketsArgs, reply *GetMarketsReply) error
GetMarkets returns all perpetual markets.
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) GetPosition ¶ added in v1.22.76
func (s *Service) GetPosition(_ *http.Request, args *GetPositionArgs, reply *GetPositionReply) error
GetPosition returns a trader's position for a market.
func (*Service) GetPositions ¶ added in v1.22.76
func (s *Service) GetPositions(_ *http.Request, args *GetPositionsArgs, reply *GetPositionsReply) error
GetPositions returns all positions for a trader.
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.
type VM ¶
type VM interface {
IsBootstrapped() bool
GetOrderbook(symbol string) (*orderbook.Orderbook, error)
GetOrCreateOrderbook(symbol string) *orderbook.Orderbook
GetLiquidityManager() *liquidity.Manager
GetPerpetualsEngine() PerpetualsEngine
GetCommitmentStore() CommitmentStore
GetADLEngine() ADLEngine
}
VM interface for the API service.