rest

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MainnetBaseURL = "https://api.mainnet.aptoslabs.com/decibel"
	TestnetBaseURL = "https://api.testnet.aptoslabs.com/decibel"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code         string `json:"code"`
	Message      string `json:"message"`
	ErrorMessage string `json:"error"`
}

func (*APIError) Error

func (e *APIError) Error() string

type AccountOverview

type AccountOverview struct {
	Account          string          `json:"account"`
	TotalBalance     decimal.Decimal `json:"total_balance"`
	AvailableBalance decimal.Decimal `json:"available_balance"`
	UnrealizedPnL    decimal.Decimal `json:"unrealized_pnl"`
	MarginBalance    decimal.Decimal `json:"margin_balance"`
}

type AccountPosition

type AccountPosition struct {
	Market                    string          `json:"market"`
	User                      string          `json:"user"`
	Side                      string          `json:"side"`
	Size                      decimal.Decimal `json:"size"`
	EntryPrice                decimal.Decimal `json:"entry_price"`
	EstimatedLiquidationPrice decimal.Decimal `json:"estimated_liquidation_price"`
	UnrealizedFunding         decimal.Decimal `json:"unrealized_funding"`
	UserLeverage              decimal.Decimal `json:"user_leverage"`
}

type Client

type Client struct {
	BaseURL    string
	Origin     string
	APIKey     string
	HTTPClient *http.Client
}

func NewClient

func NewClient(apiKey string) *Client

func (*Client) GetAccountOverview

func (c *Client) GetAccountOverview(ctx context.Context, account string) (*AccountOverview, error)

func (*Client) GetAccountPositions

func (c *Client) GetAccountPositions(ctx context.Context, account string) ([]AccountPosition, error)

func (*Client) GetMarkets

func (c *Client) GetMarkets(ctx context.Context) ([]Market, error)

func (*Client) GetOpenOrders

func (c *Client) GetOpenOrders(ctx context.Context, account string, limit int, offset int) (*OpenOrdersResponse, error)

func (*Client) GetOrder

func (c *Client) GetOrder(
	ctx context.Context,
	account string,
	market string,
	orderID string,
	clientOrderID string,
) (*OrderResponse, error)

func (*Client) GetOrderBook

func (c *Client) GetOrderBook(ctx context.Context, market string, limit int) (*OrderBookSnapshot, error)

func (*Client) GetOrderByID

func (c *Client) GetOrderByID(ctx context.Context, account, orderID string) (*OpenOrder, error)

func (*Client) GetOrderHistory

func (c *Client) GetOrderHistory(ctx context.Context, account string, limit int, offset int) (*OpenOrdersResponse, error)

func (*Client) GetTicker

func (c *Client) GetTicker(ctx context.Context, market string) (*Ticker, error)

type Market

type Market struct {
	LotSize                 decimal.Decimal `json:"lot_size"`
	MarketAddr              string          `json:"market_addr"`
	MarketName              string          `json:"market_name"`
	MaxLeverage             decimal.Decimal `json:"max_leverage"`
	MaxOpenInterest         decimal.Decimal `json:"max_open_interest"`
	MinSize                 decimal.Decimal `json:"min_size"`
	Mode                    string          `json:"mode"`
	PxDecimals              int32           `json:"px_decimals"`
	SzDecimals              int32           `json:"sz_decimals"`
	TickSize                decimal.Decimal `json:"tick_size"`
	UnrealizedPnLHaircutBps int64           `json:"unrealized_pnl_haircut_bps"`
}

type OpenOrder

type OpenOrder struct {
	ClientOrderID      string          `json:"client_order_id"`
	Market             string          `json:"market"`
	OrderID            string          `json:"order_id"`
	OrderType          string          `json:"order_type"`
	OrderDirection     string          `json:"order_direction"`
	Side               string          `json:"side"`
	IsBuy              bool            `json:"is_buy"`
	Status             string          `json:"status"`
	Details            string          `json:"details"`
	CancellationReason string          `json:"cancellation_reason"`
	IsReduceOnly       bool            `json:"is_reduce_only"`
	UnixMS             int64           `json:"unix_ms"`
	OrigSize           decimal.Decimal `json:"orig_size"`
	Price              decimal.Decimal `json:"price"`
	RemainingSize      decimal.Decimal `json:"remaining_size"`
	SizeDelta          decimal.Decimal `json:"size_delta"`
}

type OpenOrdersResponse

type OpenOrdersResponse struct {
	Items      []OpenOrder `json:"items"`
	TotalCount int         `json:"total_count"`
}

type OrderBookLevel

type OrderBookLevel struct {
	Price decimal.Decimal `json:"price"`
	Size  decimal.Decimal `json:"size"`
}

type OrderBookSnapshot

type OrderBookSnapshot struct {
	Market    string           `json:"market"`
	Bids      []OrderBookLevel `json:"bids"`
	Asks      []OrderBookLevel `json:"asks"`
	Timestamp int64            `json:"timestamp"`
}

type OrderResponse

type OrderResponse struct {
	Status  string    `json:"status"`
	Details string    `json:"details"`
	Order   OpenOrder `json:"order"`
}

type Ticker

type Ticker struct {
	Market    string          `json:"market"`
	LastPrice decimal.Decimal `json:"last_price"`
	MarkPrice decimal.Decimal `json:"mark_price"`
	BidPrice  decimal.Decimal `json:"bid_price"`
	AskPrice  decimal.Decimal `json:"ask_price"`
	Timestamp int64           `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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