Add allow unbalance options

pull/11/head v1.2.1
rkfg 2 years ago
parent 71103e9448
commit 73bc04ae21

@ -51,6 +51,8 @@ rebalance-lnd](https://github.com/accumulator/rebalance-lnd).
-r, --econ-ratio= economical ratio for fee limit calculation as a multiple of target channel fee (for
example, 0.5 means you want to pay at max half the fee you might earn for routing out of
the target channel)
-F, --fee-limit-ppm= don't consider the target channel fee and use this max fee ppm instead
(can rebalance at a loss, be careful)
-l, --lost-profit also consider the outbound channel fees when looking for profitable routes so that
outbound_fee+inbound_fee < route_fee
-b, --probe= if the payment fails at the last hop try to probe lower amount using this many steps
@ -61,6 +63,10 @@ rebalance-lnd](https://github.com/accumulator/rebalance-lnd).
-d, --exclude-node= don't use this node for routing (can be specified multiple times)
--to= try only this channel as target (should satisfy other constraints too)
--from= try only this channel as source (should satisfy other constraints too)
--allow-unbalance-from let the source channel go below 50% local liquidity, use if you want to drain a channel;
you should also set --pfrom to >50
--allow-unbalance-to let the target channel go above 50% local liquidity, use if you want to refill a channel;
you should also set --pto to >50
-s, --stat= save successful rebalance information to the specified CSV file
```

@ -40,7 +40,8 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
if _, ok := r.excludeBoth[c.ChanId]; ok {
continue
}
if c.LocalBalance < c.Capacity*toPerc/100 && c.LocalBalance+amount < c.Capacity/2 {
if c.LocalBalance < c.Capacity*toPerc/100 && (params.AllowUnbalanceTo ||
c.LocalBalance+amount < c.Capacity/2) {
if _, ok := r.excludeIn[c.ChanId]; ok {
continue
}
@ -48,7 +49,9 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
r.toChannels = append(r.toChannels, c)
}
}
if c.RemoteBalance < c.Capacity*fromPerc/100 && c.RemoteBalance+amount < c.Capacity/2 {
if c.RemoteBalance < c.Capacity*fromPerc/100 &&
(params.AllowUnbalanceFrom ||
c.RemoteBalance+amount < c.Capacity/2) {
if _, ok := r.excludeOut[c.ChanId]; ok {
continue
}
@ -101,7 +104,13 @@ func (r *regolancer) pickChannelPair(amount, minAmount int64) (from uint64, to u
fromChan = pair[0]
toChan = pair[1]
maxFrom := fromChan.Capacity/2 - fromChan.RemoteBalance
if params.AllowUnbalanceFrom {
maxFrom = fromChan.LocalBalance
}
maxTo := toChan.Capacity/2 - toChan.LocalBalance
if params.AllowUnbalanceTo {
maxTo = toChan.RemoteBalance
}
if amount == 0 {
maxAmount = min(maxFrom, maxTo)
} else {

@ -42,6 +42,8 @@ var params struct {
ExcludeNodes []string `short:"d" long:"exclude-node" description:"don't use this node for routing (can be specified multiple times)" json:"exclude_nodes" toml:"exclude_nodes"`
ToChannel uint64 `long:"to" description:"try only this channel as target (should satisfy other constraints too)" json:"to" toml:"to"`
FromChannel uint64 `long:"from" description:"try only this channel as source (should satisfy other constraints too)" json:"from" toml:"from"`
AllowUnbalanceFrom bool `long:"allow-unbalance-from" description:"let the source channel go below 50% local liquidity, use if you want to drain a channel; you should also set --pfrom to >50" json:"allow_unbalance_from" toml:"allow_unbalance_from"`
AllowUnbalanceTo bool `long:"allow-unbalance-to" description:"let the target channel go above 50% local liquidity, use if you want to refill a channel; you should also set --pto to >50" json:"allow_unbalance_to" toml:"allow_unbalance_to"`
StatFilename string `short:"s" long:"stat" description:"save successful rebalance information to the specified CSV file" json:"stat" toml:"stat"`
}

Loading…
Cancel
Save