Swim With The Tide is a simple python script that decrements the ppm on your channels when they're inactive for a given period of time.
Operations Summary:
- It uses SQLite3 to keep track of forwarding and channel infomation.
- The SQLite3 database file is
swtt.db
in the /home/swtt/swtt directory. - Deleting swtt.db will reset all channel PPM's to the specified starting value (--starting_ppm).
- The max HTLC size will be 99% of local balance (This could be optional parameter in future release)
- The base fee is set to 0, zero base fee is important for an optimized LN: https://youtu.be/WoVPkmT3gjY?t=2220
- The CLTV (Time Lock Delta) is 144 by default (Could be optional parameter in future)
- The current state of all channels is saved in the CSV swtt_current_channel_info.csv.
- Script actions and errors are logged to
swtt.log
in the same directory as the script - Channel ID's listed in the
swtt.ignore
file are ignored and not updated.
Manual run example: swtt.py -s 100 -t 1d -d 10 -m 5
-s
or --starting_ppm
Starting PPM for all new channels expressed as an integer.
(e.g. -s 100
will start the channels at 100 ppm)
-t
or --stale_time
Stale time before decrementing the ppm expressed as a string in days or hours.
(e.g. -t 2d
or -t 48h
will decrement the ppm when the channel hasn't forwarded an HTLC for 2 days)
-d
or --decrement_ppm
The amount to decrement the ppm expressed as an integer.
(e.g. -d 10
will decrement all channels by 10 ppm for every stale time cycle that passes without a forward)
-m
or --min_ppm
The minimum ppm a channel should be (ppm floor) expressed as an integer.
(e.g. -m 5
will ensure your channel charges at minimum 5 ppm, it won't go lower than this)
Review, edit and run the setup.sh
file based on your distribution, or simply run the commands one at a time.
The main things that need to be setup are:
- Add the user "swtt" and give it access to the "lnd" and "bos" groups
- Give "swtt" group access to your admin user
- Install Python and Virtual-Env
- Create the "swtt" virtual environment inside of the home dir (/home/swtt/)
- Activate Python and install required packages via pip
- Upload swtt.py to the virtual environment directory (/home/swtt/swtt/)
I suggest running the script every 30 minutes to 1 hour.
As the swtt user: crontab -e
*/30 * * * * cd /home/swtt/swtt && /home/swtt/swtt/bin/python3.9 /home/swtt/swtt/swtt.py -s 100 -t 1d -d 10 -m 5
Logs are stored in the same folder as the script: /home/swtt/swtt/swtt.log