Home Automations Rebalancing with Torq Automations

Rebalancing with Torq Automations

Last updated on Jan 19, 2024

The rebalancer has a lot of hidden attributes so it deserves it's own article. We will expand this article when more questions are sent to us about the rebalancer's internals.

To start let's state the obvious:

  • Destinations: These are the channels that you are trying to get extra local balance (your side) for. So you try to lower these channels' remote balance (other side).

  • Sources: These are the channels you decided that have excess (to much) local balance. So you want to lower your local balance (your side) and increase the remote balance (other side)

  • Amount: When the rebalancer starts working on a channels it uses this specified amount.

  • Maximum cost: Like the name says it's the maximum cost when attempting to rebalance.

We also have this odd selection field called "Focus". This focus field drives the parallelism of the rebalancer. So when you use destinations as focus then you strive to have enough local balance on the destination channels. So if 10 channels come in the workflow node as destination and 8 channels as sources then there will be 10 concurrent rebalance attempts (one for each destination). These rebalancer routines will work for a maximum of 2 hours.

As you are well aware a lot can happen in 2 hours time. So Torq does not keep a static list of channels used by it's rebalancers. So instead of keeping a static list for those 8 channels we keep the list of criteria that composed that list. Every time the rebalancer has exausted a channel pair it will reevaluate those criteria to get a fresh list of channels and look for a pair that wasn't already tried.

There currently is an arbitrary hard cap on 100 maximum concurrent rebalancer routines.

When you want to allow the rebalancer to do fast sequential rebalance operations on a successful channel pair then you need to enable the "Channel Balance Changes" trigger. However if you have a busy node and a complex rebalancing workflow it's adviced to use a "Channel Balance Changes Filter" (from the Advanced Actions section) on your datasource so you can filter out small balance changes from triggering the entire workflow. i.e. If your rebalance amount is 50,000 sats then you could filter out balance changes below 49,000 sats

The rebalance software always checks if there isn't already a rebalance routine working on your focus channel and if there is it doesn't start a new one. It will updates the details (if they changed).