Autoloop
Key Takeaways
- Autoloop automates channel rebalancing. Instead of manually executing submarine swaps when channels become unbalanced, autoloop monitors your node and triggers swaps automatically based on configurable rules and thresholds.
- Rules define when and how swaps execute. Operators set parameters like minimum/maximum channel balances, fee budgets, swap sizes, and which channels to manage. Autoloop continuously evaluates these rules and acts when conditions are met.
- Reduces operational overhead for routing nodes. High-volume routing nodes can spend hours weekly on manual liquidity management. Autoloop transforms this into a set-and-monitor operation, freeing operators for higher-value activities.
What Is Autoloop?
Autoloop is an automated liquidity management system for Lightning Network nodes that uses submarine swaps to maintain optimal channel balances without manual intervention. It was developed by Lightning Labs as part of the Loop service and has become essential infrastructure for professional node operators and Lightning Service Providers (LSPs).
The core problem autoloop solves is liquidity drift. As your node routes payments, channel balances shift. A channel that starts with balanced liquidity (50% local, 50% remote) will eventually become depleted on one side after enough payments flow through it. When a channel runs out of outbound or inbound capacity, it can no longer route payments in that direction, reducing your node's routing capabilities and fee earnings.
Before autoloop, operators had to manually monitor channels, decide when to rebalance, and execute submarine swaps through the Loop service or similar providers. This process required constant attention and expertise. Autoloop codifies this expertise into rules that execute automatically, turning liquidity management from an active task into a passive system.
The "auto" in autoloop refers to this automation layer built on top of the Loop submarine swap service. Loop provides the underlying swap mechanism; autoloop provides the intelligence to use it effectively without human intervention.
How Autoloop Works
Autoloop operates as a daemon that continuously monitors your node's channel states and compares them against your configured rules. When channels fall outside acceptable parameters, autoloop initiates submarine swaps to restore balance.
The Monitoring Loop
Autoloop follows a continuous cycle:
- Scan channels: Periodically check the balance state of all channels (or a configured subset).
- Evaluate rules: Compare each channel's current balance against defined thresholds. Identify channels that need loop-in (more inbound) or loop-out (more outbound).
- Check constraints: Verify that proposed swaps fit within fee budgets, in-flight limits, and other constraints.
- Execute swaps: Initiate submarine swaps for channels that meet all criteria.
- Wait and repeat: After a configurable interval, restart the cycle.
Rule-Based Decision Making
The power of autoloop comes from its rules engine. Operators define parameters that control swap behavior:
- Balance thresholds: Minimum and maximum acceptable local balance as a percentage or absolute amount. A channel at 10% local balance might trigger a loop-out; one at 90% might trigger a loop-in.
- Fee limits: Maximum acceptable swap fees (both on-chain and off-chain). Autoloop will wait for better fee conditions rather than overpay.
- Swap size ranges: Minimum and maximum swap amounts. Larger swaps are more fee-efficient but tie up more capital during execution.
- Channel selection: Which channels to manage automatically. High-volume routing channels might get aggressive management; backup channels might be excluded.
- Budget constraints: Total fee budget per time period, preventing runaway costs during volatile fee environments.
Loop In vs Loop Out
Autoloop manages two types of submarine swaps, each addressing a different liquidity problem:
Loop Out
A loop-out swap converts Lightning funds to on-chain Bitcoin. You send sats through a Lightning payment and receive Bitcoin to an on-chain address. This is used when you have too much local (outbound) capacity and need more inbound capacity.
After routing many incoming payments, your channels accumulate local balance. Loop-out moves this excess to on-chain, creating room for more inbound payments. The on-chain Bitcoin can be used to open new channels, held in cold storage, or converted to fiat.
Loop In
A loop-in swap converts on-chain Bitcoin to Lightning funds. You send Bitcoin on-chain and receive it as incoming Lightning liquidity. This is used when you have too much remote (inbound) capacity and need more outbound capacity.
After routing many outgoing payments, your channels deplete local balance. Loop-in replenishes outbound capacity using on-chain funds. This is common for nodes that serve as payment sources or need consistent sending capability.
Bidirectional Management
Most autoloop configurations use both loop-in and loop-out to maintain a target balance range. A typical configuration might aim for 40-60% local balance on routing channels. When local balance drops below 40%, autoloop triggers loop-in. When it rises above 60%, autoloop triggers loop-out. This bidirectional approach keeps channels optimally positioned for routing in either direction.
Configuration Strategies
Conservative Configuration
New operators often start with conservative settings: wide balance thresholds (20-80%), strict fee limits, and lower budgets. This approach minimizes swap costs while learning how your node's liquidity naturally flows. Over time, you can tighten thresholds and increase budgets based on observed routing patterns.
Aggressive Configuration
High-volume routing nodes may use aggressive settings: tight balance thresholds (40-60%), higher fee tolerance, and larger budgets. The additional swap costs are offset by increased routing revenue from maintaining optimal liquidity positions. Professional operators often find that underbalanced channels cost more in lost routing fees than proactive rebalancing.
Channel-Specific Rules
Not all channels deserve equal treatment. Autoloop supports per-channel configuration. You might configure:
- High-volume peers: Tight thresholds, higher priority, larger swap sizes
- Strategic channels: Maintain specific balance ratios based on expected flow direction
- Low-priority channels: Wide thresholds or exclusion from automation
- New channels: Initial settling period before automation kicks in
Cost Optimization
Submarine swaps involve costs: on-chain transaction fees, swap service fees, and Lightning routing fees. Autoloop includes features to minimize these costs:
Fee-Aware Timing
Autoloop can delay non-urgent swaps until fee conditions improve. If on-chain fees are elevated, autoloop waits rather than executing expensive swaps. Configurable fee limits ensure you never overpay during fee spikes.
Batching and Sizing
Larger swaps are more efficient per satoshi moved. Autoloop can aggregate multiple small-balance channels into single larger swaps, reducing per-satoshi overhead. Minimum swap sizes prevent inefficient micro-swaps.
Budget Controls
Time-based budgets (daily, weekly, monthly) prevent cost overruns. If fees are consistently high, autoloop respects budget limits rather than depleting funds on expensive swaps. This provides predictable operating costs for node operators.
Swap Provider Selection
While autoloop was built for Lightning Labs' Loop service, the concept has inspired similar automation for other swap providers. Some operators run multiple automation systems to access different liquidity sources and fee structures.
Use Cases and Operator Profiles
Lightning Service Providers (LSPs)
LSPs serving wallets and applications face constant liquidity demands. Customer payments flow in one direction, quickly depleting channel capacity. Autoloop enables LSPs to maintain service quality without dedicating staff to manual rebalancing. The automation scales with customer growth.
Professional Routing Nodes
Operators running routing nodes for fee revenue depend on balanced channels. Unbalanced channels miss routing opportunities. Autoloop keeps channels in optimal routing position, maximizing fee capture. The cost of swaps is factored into routing profitability calculations.
Merchant Payment Processors
Businesses receiving Lightning payments accumulate inbound capacity and deplete outbound capacity. Autoloop converts incoming payments to on-chain funds automatically, maintaining receiving capability. This is especially valuable for high-volume merchants.
Exchange and Custodian Nodes
Exchanges moving funds between Lightning and on-chain benefit from automated liquidity management. Autoloop maintains the capacity needed for customer withdrawals and deposits without manual treasury operations.
FAQ
Manual loop requires you to monitor channels, decide when to swap, and execute each swap individually. Autoloop monitors continuously and executes swaps automatically based on your configured rules. The underlying submarine swap mechanism is identical; autoloop adds the automation and decision-making layer.
Integrate Lightning the Easy Way
The simplest, cheapest, and fastest way to add Lightning payments to your app with the Spark SDK.
View SDK Docs →