If your node has many channels and an average liquidity, you will notice that manual fees adjustment is neither efficient nor productive, then an automated way to do this is necessary to be implemented. This might not be the case if you are running a node at home for personal use, but it is for sure if you are doing some kind of activity with your node, for example routing transactions with some higher liquidity available.
On the Lightning Network, fees are applied on a per-channel basis. Each peer has the flexibility to establish their fee policies for all the channels they are involved in.
Fees mechanics
These fees come into play when you initiate a payment from your node to a neighboring node, affecting the outgoing channel liquidity by charging you a fee.
Due to the structure of the lightning network, it's important to note that fees are only incurred when a payment is successfully completed, as each node along the payment path can only claim their fees if the recipient confirms that the payment has been successfully received.
Outbound liquidity resides on the node's side of the connected channels. In this scenario, nodes maintain control over the fees charged on outbound liquidity transactions. This control grants nodes the ability to manage and adjust fees according to their preferences.
Adjusting fees
It’s often necessary to adjust dynamically the fees of all our channels in order to “manipulate” the flows of transactions (forwards) inside our node and change balancing according to our preferences and strategies.
For this reason fees applied to channels should never be static and kept as the same. A strategy for automatic change of them is necessary.
For node runners, running LND implementation, autofees function is available on Lightning terminal for this purpose. Or you can use specialized scripts like charge-lnd. In case of the lightning terminal, the function “autofees” is created to reduce the maintenance overhead of a routing node while trying to increase forwards flows and net revenue.
First thing to notice is that you can enable this feature globally but disable for specific channels, getting more granularity in this way.
How fees are managed?
How does it do? To determine a target throughput per peer, it considers the forwarded traffic of the top five earning peers over a 60-day period. This makes statistic data available for further calculations. Subsequently, it assesses the recent forwarded traffic and makes fee adjustments, either upward or downward, for each peer. This algorithm's primary goal is to maintain traffic stability, prevent under-pricing of liquidity, and adapt effectively to shifts in demand and routing patterns. And these are exactly the goals you are searching for.
When the forwarded traffic of a channel falls below the target throughput, fees are reduced. Conversely, if the forwarded traffic exceeds the target, fees are raised. These fee adjustments are implemented gradually, with small increments, occurring once every three days. This approach strikes a balance by controlling network gossip data while fine-tuning fee structures.
When a channel experiences a depletion of 7/8th of its liquidity, fees are incrementally because of increased scarcity. This proactive step is taken to maintain channel equilibrium and reserve liquidity for periods of heightened demand. This also reduces forwarding failures.