tradeclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNullTradeCompleteOpts ...
	ErrNullTradeCompleteOpts = errors.New("swap complete and swap fail messages must not be both null")
	// ErrInvalidTradeCompleteOpts ...
	ErrInvalidTradeCompleteOpts = errors.New("swap complete and swap fail messages must not be both defined")
	// ErrInvalidSwapCompleteMessage ...
	ErrInvalidSwapCompleteMessage = errors.New("swap complete must be a valid serialized message")
	// ErrInvalidSwapFailMessage ...
	ErrInvalidSwapFailMessage = errors.New("swap fail must be a valid serialized message")
)
View Source
var (
	// ErrMalformedSwapRequestMessage ...
	ErrMalformedSwapRequestMessage = errors.New("swap request must be a valid serialized message")
)

Functions

This section is empty.

Types

type BalancesOpts

type BalancesOpts struct {
	Market trademarket.Market
}

BalancesOpts is the struct given to Balances method

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client allows to connect with a trader service and to call its RPCs

func NewTradeClient

func NewTradeClient(host string, port int) (*Client, error)

NewTradeClient returns a new Client connected to the server at the given host and port through an insecure connection

func (*Client) CloseConnection

func (c *Client) CloseConnection() error

CloseConnection closes the connections between the current client and the server

func (*Client) GetMarketBalance added in v0.8.9

func (c *Client) GetMarketBalance(opts BalancesOpts) (*tdexv2.GetMarketBalanceResponse, error)

Balances crafts the request and calls the Balances rpc

func (*Client) Markets

func (c *Client) Markets() (*tdexv2.ListMarketsResponse, error)

Markets calls the Markets rpc and returns its response

func (*Client) PreviewTrade added in v0.8.9

func (c *Client) PreviewTrade(opts PreviewTradeOpts) (*tdexv2.PreviewTradeResponse, error)

PreviewTrade crafts the request and calls the PreviewTrade rpc

func (*Client) TradeComplete

func (c *Client) TradeComplete(opts TradeCompleteOpts) (*tdexv2.CompleteTradeResponse, error)

TradeComplete crafts the request and calls the TradeComplete rpc

func (*Client) TradePropose

func (c *Client) TradePropose(opts TradeProposeOpts) (*tdexv2.ProposeTradeResponse, error)

TradePropose crafts the request and calls the TradePropose rpc

type PreviewTradeOpts added in v0.8.9

type PreviewTradeOpts struct {
	Market    trademarket.Market
	TradeType tradetype.TradeType
	Amount    uint64
	Asset     string
	FeeAsset  string
}

PreviewTradeOpts is the struct given to PreviewTrade method

type TradeCompleteOpts

type TradeCompleteOpts struct {
	SwapComplete []byte
	SwapFail     []byte
}

TradeCompleteOpts is the struct given to TradeComplete method

type TradeProposeOpts

type TradeProposeOpts struct {
	Market      trademarket.Market
	SwapRequest []byte
	TradeType   tradetype.TradeType
}

TradeProposeOpts is the struct given to TradePropose method

Jump to

Keyboard shortcuts

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