application

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

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
	PriceFeederSvc      ports.PriceFeeder
	FeeBalanceThreshold uint64
	TradePriceSlippage  decimal.Decimal
	TxSatsPerByte       decimal.Decimal
	// contains filtered or unexported fields
}

func (*Config) FeederService added in v1.0.0

func (c *Config) FeederService() FeederService

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) UnlockerService added in v1.0.0

func (c *Config) UnlockerService() UnlockerService

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 FeederService added in v1.0.0

type FeederService interface {
	AddPriceFeed(
		ctx context.Context, market ports.Market, source, ticker string,
	) (string, error)
	StartPriceFeed(ctx context.Context, id string) error
	StopPriceFeed(ctx context.Context, id string) error
	UpdatePriceFeed(ctx context.Context, id, source, ticker string) error
	RemovePriceFeed(ctx context.Context, id string) error
	GetPriceFeed(ctx context.Context, id string) (ports.PriceFeedInfo, error)
	ListSources(ctx context.Context) []string
	ListPriceFeeds(ctx context.Context) ([]ports.PriceFeedInfo, error)
	Close()
}

func NewFeederService added in v1.0.0

func NewFeederService(
	feederSvc ports.PriceFeeder, repoManager ports.RepoManager,
) (FeederService, error)

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,
		password string, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)

	// Market account
	NewMarket(
		ctx context.Context,
		market ports.Market, marketName string,
		basePercentageFee, quotePercentageFee, baseFixedFee, quoteFixedFee uint64,
		baseAssetPrecision, quoteAssetPrecision, strategyType uint,
	) (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,
		password string, market ports.Market, outputs []ports.TxOutput, millisatsPerByte uint64,
	) (string, error)
	UpdateMarketPercentageFee(
		ctx context.Context,
		market ports.Market, baseFee, quoteFee int64,
	) (ports.MarketInfo, error)
	UpdateMarketFixedFee(
		ctx context.Context,
		market ports.Market, baseFixedFee, quoteFixedFee int64,
	) (ports.MarketInfo, error)
	UpdateMarketAssetsPrecision(
		ctx context.Context,
		market ports.Market, baseAssetPrecision, quoteAssetPrecision int,
	) 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,
		password string, 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,
		password string, 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, event ports.WebhookEvent,
	) ([]ports.WebhookInfo, error)
}

func NewOperatorService

func NewOperatorService(
	walletSvc WalletService, pubsubSvc PubSubService,
	repoManager ports.RepoManager, feeAccountBalanceThreshold uint64,
	satsPerByte decimal.Decimal,
) (OperatorService, error)

type PubSubService added in v1.0.0

type PubSubService interface {
	SecurePubSub() ports.SecurePubSub
	AddWebhook(ctx context.Context, hook ports.Webhook) (string, error)
	AddWebhookWithID(ctx context.Context, hook ports.Webhook) (string, error)
	RemoveWebhook(ctx context.Context, id string) error
	ListWebhooks(
		ctx context.Context, event ports.WebhookEvent,
	) ([]ports.WebhookInfo, error)
	PublisAccountLowBalanceEvent(
		accountName string, accountBalance map[string]ports.Balance,
		market ports.Market,
	) error
	PublisAccountWithdrawEvent(
		accountName string, accountBalance map[string]ports.Balance,
		withdrawal domain.Withdrawal, market ports.Market,
	) error
	PublishTradeSettledEvent(
		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)
	GetMarketPrice(
		ctx context.Context, market ports.Market,
	) (decimal.Decimal, uint64, error)
	TradePreview(
		ctx context.Context, market ports.Market,
		tradeType ports.TradeType, amount uint64, asset, feeAsset 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, satsPerByte decimal.Decimal,
) (TradeService, error)

type UnlockerService added in v1.0.0

type UnlockerService interface {
	GenSeed(ctx context.Context) ([]string, error)
	InitWallet(ctx context.Context, mnemonic []string, password string) error
	RestoreWallet(ctx context.Context, mnemonic []string, password string) error
	UnlockWallet(ctx context.Context, password string) error
	LockWallet(ctx context.Context, password string) error
	ChangePassword(ctx context.Context, oldPwd, newPwd string) error
	Status(ctx context.Context) (ports.WalletStatus, error)
	Info(ctx context.Context) (ports.WalletInfo, error)
}

func NewUnlockerService added in v1.0.0

func NewUnlockerService(
	walletSvc WalletService, pubsubSvc PubSubService,
) (UnlockerService, 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, msatsPerByte uint64,
	) (string, error)
	CompleteSwap(
		account string, swapRequest ports.SwapRequest, msatsPerByte uint64,
		feesToAdd bool,
	) (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