application

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBBadger = "badger"
)

Variables

View Source
var (
	SupportedDBType = map[string]struct{}{
		DBBadger: {},
	}
)

Functions

This section is empty.

Types

type Config added in v1.0.0

type Config struct {
	DBType   string
	DBConfig interface{}

	OceanWallet         ports.WalletService
	SecurePubSub        ports.SecurePubSub
	MarketPercentageFee uint32
	FeeBalanceThreshold uint64
	TradePriceSlippage  decimal.Decimal
	// contains filtered or unexported fields
}

func (*Config) OperatorService added in v1.0.0

func (c *Config) OperatorService() OperatorService

func (*Config) PubSubService added in v1.0.0

func (c *Config) PubSubService() PubSubService

func (*Config) RepoManager added in v1.0.0

func (c *Config) RepoManager() ports.RepoManager

func (*Config) TradeService added in v1.0.0

func (c *Config) TradeService() TradeService

func (*Config) Validate added in v1.0.0

func (c *Config) Validate() error

func (*Config) WalletService added in v1.0.0

func (c *Config) WalletService() WalletService

type OperatorService

type OperatorService interface {
	// Fee account
	DeriveFeeAddresses(ctx context.Context, num int) ([]string, error)
	ListFeeExternalAddresses(ctx context.Context) ([]string, error)
	GetFeeBalance(ctx context.Context) (ports.Balance, error)
	WithdrawFeeFunds(
		ctx context.Context, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)

	// Market account
	NewMarket(ctx context.Context, market ports.Market) (ports.MarketInfo, error)
	GetMarketInfo(
		ctx context.Context, market ports.Market,
	) (ports.MarketInfo, error)
	DeriveMarketAddresses(
		ctx context.Context, market ports.Market, num int,
	) ([]string, error)
	ListMarketExternalAddresses(
		ctx context.Context, market ports.Market,
	) ([]string, error)
	GetMarketReport(
		ctx context.Context, market ports.Market,
		timeRange ports.TimeRange, groupByTimeFrame int,
	) (ports.MarketReport, error)
	OpenMarket(ctx context.Context, market ports.Market) error
	CloseMarket(ctx context.Context, market ports.Market) error
	DropMarket(ctx context.Context, market ports.Market) error
	WithdrawMarketFunds(
		ctx context.Context,
		market ports.Market, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)
	UpdateMarketPercentageFee(
		ctx context.Context, market ports.Market, basisPoint uint32,
	) (ports.MarketInfo, error)
	UpdateMarketFixedFee(
		ctx context.Context,
		market ports.Market, baseFixedFee, quoteFixedFee int64,
	) (ports.MarketInfo, error)
	UpdateMarketPrice(
		ctx context.Context,
		market ports.Market, basePrice, quotePrice decimal.Decimal,
	) error
	UpdateMarketStrategy(
		ctx context.Context, market ports.Market, strategyType int,
	) error

	// Fee Fragmenter account
	DeriveFeeFragmenterAddresses(ctx context.Context, num int) ([]string, error)
	ListFeeFragmenterExternalAddresses(ctx context.Context) ([]string, error)
	GetFeeFragmenterBalance(
		ctx context.Context,
	) (map[string]ports.Balance, error)
	FeeFragmenterSplitFunds(
		ctx context.Context, maxFragments uint32, millisatsPerByte uint64,
		chRes chan ports.FragmenterReply,
	)
	WithdrawFeeFragmenterFunds(
		ctx context.Context, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)

	// Market fragmenter account
	DeriveMarketFragmenterAddresses(
		ctx context.Context, numOfAddresses int,
	) ([]string, error)
	ListMarketFragmenterExternalAddresses(ctx context.Context) ([]string, error)
	GetMarketFragmenterBalance(
		ctx context.Context,
	) (map[string]ports.Balance, error)
	MarketFragmenterSplitFunds(
		ctx context.Context, market ports.Market, millisatsPerByte uint64,
		chRes chan ports.FragmenterReply,
	)
	WithdrawMarketFragmenterFunds(
		ctx context.Context, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)

	// List methods
	ListMarkets(ctx context.Context) ([]ports.MarketInfo, error)
	ListTradesForMarket(
		ctx context.Context, market ports.Market, page ports.Page,
	) ([]ports.Trade, error)
	ListUtxos(
		ctx context.Context, accountName string, page ports.Page,
	) ([]ports.Utxo, []ports.Utxo, error)
	ListDeposits(
		ctx context.Context, accountName string, page ports.Page,
	) ([]ports.Deposit, error)
	ListWithdrawals(
		ctx context.Context, accountName string, page ports.Page,
	) ([]ports.Withdrawal, error)

	// Webhook
	AddWebhook(ctx context.Context, hook ports.Webhook) (string, error)
	RemoveWebhook(ctx context.Context, id string) error
	ListWebhooks(ctx context.Context, actionType int) ([]ports.WebhookInfo, error)
}

func NewOperatorService

func NewOperatorService(
	walletSvc WalletService, pubsubSvc PubSubService,
	repoManager ports.RepoManager,
	marketPercentageFee uint32, feeAccountBalanceThreshold uint64,
) (OperatorService, error)

type PubSubService added in v1.0.0

type PubSubService interface {
	SecurePubSub() ports.SecurePubSub
	PublisAccountLowBalanceTopic(
		accountName string, accountBalance map[string]ports.Balance,
		market ports.Market,
	) error
	PublisAccountWithdrawTopic(
		accountName string, accountBalance map[string]ports.Balance,
		withdrawal domain.Withdrawal, market ports.Market,
	) error
	PublishTradeSettledTopic(
		accountName string, accountBalance map[string]ports.Balance,
		trade domain.Trade,
	) error
	Close()
}

func NewPubSubService added in v1.0.0

func NewPubSubService(pubsubSvc ports.SecurePubSub) PubSubService

type TradeService

type TradeService interface {
	GetTradableMarkets(ctx context.Context) ([]ports.MarketInfo, error)
	TradePreview(
		ctx context.Context, market ports.Market,
		tradeType ports.TradeType, amount uint64, asset string,
	) (ports.TradePreview, error)
	TradePropose(
		ctx context.Context, market ports.Market,
		tradeType ports.TradeType, swapRequest ports.SwapRequest,
	) (ports.SwapAccept, ports.SwapFail, int64, error)
	TradeComplete(
		ctx context.Context,
		swapComplete ports.SwapComplete, swapFail ports.SwapFail,
	) (string, ports.SwapFail, error)
	GetMarketBalance(
		ctx context.Context, market ports.Market,
	) (ports.MarketInfo, error)
}

func NewTradeService

func NewTradeService(
	walletSvc WalletService, pubsubSvc PubSubService,
	repoManager ports.RepoManager,
	priceSlippage decimal.Decimal,
) (TradeService, error)

type WalletService

type WalletService interface {
	Wallet() ports.Wallet
	Account() ports.Account
	Transaction() ports.Transaction
	Notification() ports.Notification
	Network() network.Network
	NativeAsset() string
	SendToMany(
		account string, outs []ports.TxOutput, millisatPerByte uint64,
	) (string, error)
	CompleteSwap(
		account string, swapRequest ports.SwapRequest,
	) (string, []ports.Utxo, int64, error)
	RegisterHandlerForTxEvent(handler func(ports.WalletTxNotification) bool)
	RegisterHandlerForUtxoEvent(handler func(ports.WalletUtxoNotification) bool)
	Close()
}

func NewWalletService

func NewWalletService(w ports.WalletService) (WalletService, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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