trade

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServiceUnavailable = fmt.Errorf("service is unavailable, retry later")
	ErrMarketUnavailable  = fmt.Errorf("market is closed, retry later")
)

Functions

This section is empty.

Types

type Service

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

func NewService

func NewService(
	walletSvc *wallet.Service,
	pubsubSvc *pubsub.Service,
	repoManager ports.RepoManager,
	priceSlippage, satsPerByte decimal.Decimal,
) (*Service, error)

func (*Service) GetMarketBalance

func (s *Service) GetMarketBalance(
	ctx context.Context, market ports.Market,
) (ports.MarketInfo, error)

func (*Service) GetMarketPrice

func (s *Service) GetMarketPrice(
	ctx context.Context, market ports.Market,
) (decimal.Decimal, uint64, error)

func (*Service) GetTradableMarkets

func (s *Service) GetTradableMarkets(ctx context.Context) ([]ports.MarketInfo, error)

func (*Service) TradeComplete

func (s *Service) TradeComplete(
	ctx context.Context,
	swapComplete ports.SwapComplete, swapFail ports.SwapFail,
) (txidRes string, swapFailRes ports.SwapFail, err error)

func (*Service) TradePreview

func (s *Service) TradePreview(
	ctx context.Context, market ports.Market,
	tradeType ports.TradeType, amount uint64, asset, feeAsset string,
) (ports.TradePreview, error)

func (*Service) TradePropose

func (s *Service) TradePropose(
	ctx context.Context, market ports.Market,
	tradeType ports.TradeType, swapRequest ports.SwapRequest,
) (ports.SwapAccept, ports.SwapFail, int64, error)

Jump to

Keyboard shortcuts

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