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 ¶
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 ¶
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.