Skip to content

Commit

Permalink
Simplify RebalanceAll interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nyonson committed Apr 13, 2023
1 parent b103efb commit eadce0a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# dashboard

`raiju`'s root command, `raiju`, fires up an interactive TUI dashboard.
`raiju`'s root command, `raiju`, fires up an interactive TUI dashboard which uses the subcommands under the hood.

# subcommands

Expand Down
2 changes: 1 addition & 1 deletion cmd/raiju/raiju.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func main() {
cmdLog.Printf("rebalanced %f percent with a %d sat fee\n", percent, fee)
} else {
cmdLog.Println("Rebalancing all channels...")
rebalanced, err := r.RebalanceAll(ctx, stepPercent, maxPercent, maxFee)
rebalanced, err := r.RebalanceAll(ctx, stepPercent, maxPercent)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions raiju.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (r Raiju) Rebalance(ctx context.Context, outChannelID lightning.ChannelID,
}

// RebalanceAll high local liquidity channels into low liquidity channels, return percent rebalanced per channel attempted.
func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent float64, maxFee lightning.FeePPM) (map[lightning.ChannelID]float64, error) {
func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent float64) (map[lightning.ChannelID]float64, error) {
local, err := r.l.GetInfo(ctx)
if err != nil {
return map[lightning.ChannelID]float64{}, err
Expand Down Expand Up @@ -394,7 +394,7 @@ func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent
}
potentialLocal := lightning.Satoshi(float64(h.Capacity) * maxPercent)
if r.f.PotentialFee(ul, potentialLocal) != r.f.Fee(ul) {
p, f, err := r.Rebalance(ctx, h.ChannelID, lastHopPubkey, stepPercent, (maxPercent - percentRebalanced), maxFee)
p, f, err := r.Rebalance(ctx, h.ChannelID, lastHopPubkey, stepPercent, (maxPercent - percentRebalanced), r.f.RebalanceFee())
if err != nil {
return map[lightning.ChannelID]float64{}, err
}
Expand Down
4 changes: 1 addition & 3 deletions raiju_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ func TestRaiju_RebalanceAll(t *testing.T) {
ctx context.Context
stepPercent float64
maxPercent float64
maxFee lightning.FeePPM
}
tests := []struct {
name string
Expand Down Expand Up @@ -753,7 +752,6 @@ func TestRaiju_RebalanceAll(t *testing.T) {
args: args{
stepPercent: 1,
maxPercent: 5,
maxFee: 10,
},
want: map[lightning.ChannelID]float64{},
wantErr: false,
Expand All @@ -764,7 +762,7 @@ func TestRaiju_RebalanceAll(t *testing.T) {
r := Raiju{
l: tt.fields.l,
}
got, err := r.RebalanceAll(tt.args.ctx, tt.args.stepPercent, tt.args.maxPercent, tt.args.maxFee)
got, err := r.RebalanceAll(tt.args.ctx, tt.args.stepPercent, tt.args.maxPercent)
if (err != nil) != tt.wantErr {
t.Errorf("Raiju.RebalanceAll() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down

0 comments on commit eadce0a

Please sign in to comment.