liquidity

package
v0.9.0-beta Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package liquidity is responsible for monitoring our node's liquidity. It allows setting of a liquidity rule which describes the desired liquidity balance on a per-channel basis.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrZeroChannelID is returned if we get a rule for a 0 channel ID.
	ErrZeroChannelID = fmt.Errorf("zero channel ID not allowed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// LoopOutRestrictions returns the restrictions that the server applies
	// to loop out swaps.
	LoopOutRestrictions func(ctx context.Context) (*Restrictions, error)

	// Lnd provides us with access to lnd's main rpc.
	Lnd lndclient.LightningClient
}

Config contains the external functionality required to run the liquidity manager.

type LoopOutRecommendation

type LoopOutRecommendation struct {
	// Amount is the total amount to swap.
	Amount btcutil.Amount

	// Channel is the target outgoing channel.
	Channel lnwire.ShortChannelID
}

LoopOutRecommendation contains the information required to recommend a loop out.

type Manager

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

Manager contains a set of desired liquidity rules for our channel balances.

func NewManager

func NewManager(cfg *Config) *Manager

NewManager creates a liquidity manager which has no rules set.

func (*Manager) GetParameters

func (m *Manager) GetParameters() Parameters

GetParameters returns a copy of our current parameters.

func (*Manager) SetParameters

func (m *Manager) SetParameters(params Parameters) error

SetParameters updates our current set of parameters if the new parameters provided are valid.

func (*Manager) SuggestSwaps

func (m *Manager) SuggestSwaps(ctx context.Context) (
	[]*LoopOutRecommendation, error)

SuggestSwaps returns a set of swap suggestions based on our current liquidity balance for the set of rules configured for the manager, failing if there are no rules set.

type Parameters

type Parameters struct {
	// ChannelRules maps a short channel ID to a rule that describes how we
	// would like liquidity to be managed.
	ChannelRules map[lnwire.ShortChannelID]*ThresholdRule
}

Parameters is a set of parameters provided by the user which guide how we assess liquidity.

func (Parameters) String

func (p Parameters) String() string

String returns the string representation of our parameters.

type Restrictions

type Restrictions struct {
	// Minimum is the minimum amount we can swap, inclusive.
	Minimum btcutil.Amount

	// Maximum is the maximum amount we can swap, inclusive.
	Maximum btcutil.Amount
}

Restrictions indicates the restrictions placed on a swap.

func NewRestrictions

func NewRestrictions(minimum, maximum btcutil.Amount) *Restrictions

NewRestrictions creates a set of restrictions.

func (*Restrictions) String

func (r *Restrictions) String() string

String returns a string representation of a set of restrictions.

type ThresholdRule

type ThresholdRule struct {
	// MinimumIncoming is the percentage of incoming liquidity that we do
	// not want to drop below.
	MinimumIncoming int

	// MinimumOutgoing is the percentage of outgoing liquidity that we do
	// not want to drop below.
	MinimumOutgoing int
}

ThresholdRule is a liquidity rule that implements minimum incoming and outgoing liquidity threshold.

func NewThresholdRule

func NewThresholdRule(minIncoming, minOutgoing int) *ThresholdRule

NewThresholdRule returns a new threshold rule.

func (*ThresholdRule) String

func (r *ThresholdRule) String() string

String returns a string representation of a rule.

Jump to

Keyboard shortcuts

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