Skip to content

Commit

Permalink
Hotfix, the simplification introduced a condition when the channel wa…
Browse files Browse the repository at this point in the history
…s already balanced, it tried to balance it. (#76)
  • Loading branch information
Jossec101 authored Apr 17, 2024
1 parent 245b205 commit 8dce412
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions liquidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,36 +466,32 @@ func manageChannelLiquidity(info ManageChannelLiquidityInfo) error {
span.SetAttributes(attribute.String("nodeAlias", info.nodeInfo.GetAlias()))

log.WithField("span", span).Infof("rebalancing via invoice on channel %v on node %v", channel.GetChanId(), info.nodeInfo.GetAlias())
var payerPubKey string
var payeePubKey string
var swapAmount int64

switch {
//Create an invoice for the swap amount from the remote node and pay with the rule's node
case rule.MinimumLocalBalance != 0 && info.channelBalanceRatio < float64(rule.MinimumLocalBalance):
{
swapAmount = helper.AbsInt64((swapAmountTarget - channel.LocalBalance))
swapAmount := helper.AbsInt64((swapAmountTarget - channel.LocalBalance))

payerPubKey = rule.NodePubkey
payeePubKey = rule.RemoteNodePubkey
err := invoiceRebalance(info, swapAmount, rule.NodePubkey, rule.RemoteNodePubkey)
if err != nil {
return err
}

}
//Create an invoice for the swap amount from the rule's node and pay with the remote node
case rule.MinimumRemoteBalance != 0 && info.channelBalanceRatio > float64(rule.MinimumRemoteBalance):
{
swapAmount = helper.AbsInt64((channel.RemoteBalance - swapAmountTarget))
swapAmount := helper.AbsInt64((channel.RemoteBalance - swapAmountTarget))

payerPubKey = rule.RemoteNodePubkey
payeePubKey = rule.NodePubkey
err := invoiceRebalance(info, swapAmount, rule.RemoteNodePubkey, rule.NodePubkey)
if err != nil {
return err
}
}

}

err := invoiceRebalance(info, swapAmount, payerPubKey, payeePubKey)
if err != nil {
return err
}

}
case rule.MinimumLocalBalance != 0 && info.channelBalanceRatio < float64(rule.MinimumLocalBalance):
{
Expand Down

0 comments on commit 8dce412

Please sign in to comment.