1
1
#! /bin/bash
2
2
# A sample Bash script, by Hakuna
3
- # ToDo:
4
- # 1) In case the below LND directory doesn't work for you, add a direct link in line 22
5
- # 2) Secondly, alternate the path to your rebalance-lnd directory if it's not in ~/rebalance-lnd/ in line 18 (umbrel) or line 24 (!umbrel)
3
+ # ToDo:
4
+ # 1) In case the below LND directory doesn't work for you, add a direct link in line 18
5
+ # 2) Secondly, alternate the path to your rebalance-lnd directory if it's not in ~/rebalance-lnd/ in line 13 (umbrel) or line 19 (!umbrel)
6
6
7
- activate () {
8
- . ../.venv/bin/activate
9
- source ~ /venv/bin/activate
10
- }
11
- activate
12
7
13
8
# Set LN-Path & Rebalance-LND
14
9
if [ " ` uname -a | grep umbrel` " != " " ]
15
- then
10
+ then
16
11
# LNPATH setting on umbrel
17
12
LNPATH=" ~/umbrel/lnd/"
18
13
RLND=" /home/umbrel/rebalance-lnd/rebalance.py"
14
+ umbrel=1
19
15
else
20
16
# Other installations
21
17
# Set your own Path to LND in case the below does not work for you
22
18
LNPATH=" ~/.lnd/"
23
- # Adjust this directory in case you installed Rebalance-LND somewhere different
19
+ # Adjust this directory in case you installed Rebalance-LND somewhere different
24
20
RLND=" /home/admin/apps/rebalance-lnd/rebalance.py"
21
+ umbrel=0
25
22
fi
26
23
24
+ activate () {
25
+ if [ $umbrel = 1 ]
26
+ then
27
+ source ~ /venv/bin/activate
28
+ else
29
+ . ../.venv/bin/activate
30
+ fi
31
+ }
32
+ activate
33
+
27
34
helpFunction ()
28
35
{
29
36
echo " FUCK $1 - something went wrong"
54
61
helpFunction
55
62
fi
56
63
57
- rebalance_something ()
64
+ rebalance_something ()
58
65
{
59
66
60
67
if [ $direction == ' 👉Push' ]
@@ -63,18 +70,27 @@ if [ $direction == '👉Push' ]
63
70
else
64
71
direction=' t'
65
72
fi
73
+ if [ $amountoption == ' Defined' ]
74
+ then
75
+ let a=$amountvalue /5
76
+ python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -a $a
77
+ python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -a $a
78
+ python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -a $a
79
+ python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -a $a
80
+ python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -a $a
81
+ else
66
82
python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -p $2
67
83
python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -p $3
68
84
python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -p $4
69
85
python $RLND --lnddir $LNPATH --$feeoption $feevalue -$direction $1 -p $5
70
- python $RLND --lnddir $LNPATH -- $feeoption $feevalue - $direction $1
86
+ fi
71
87
}
72
88
73
89
rebalance_start ()
74
90
{
75
91
# Channel 1
76
92
echo " Starting the rebalancing on Channel 1"
77
- rebalance_something $parameterJ 10 30 50 70
93
+ rebalance_something $parameterJ 10 30 50 70 # adjust string for function to pick up -a or -p
78
94
79
95
if [ -z " $parameterK " ]
80
96
then
127
143
}
128
144
129
145
# Direction-Selection Process
130
- echo -e " ===================================================================================================================================="
131
146
echo -e " "
132
- echo -e " \t You have successfully added one or more channels to be rebalanced. Now define where the liquidity should move to."
147
+ echo -e " [DIRECTION-SELECTION PROCESS]======================================================================================================="
148
+ echo -e " You have successfully added one or more channels to be rebalanced. Now define where the liquidity should move to."
133
149
echo -e " "
134
150
echo -e " \t - 👉 Pushing liquidity indicates low inbound, high amount of local outbound sats"
135
151
echo -e " \t - 👈 Pulling liquidity indicates high inbound, low amount of local outbound sats"
@@ -145,7 +161,9 @@ break
145
161
done
146
162
147
163
# Fee-Selection Process
148
- echo -e " ===================================================================================================================================="
164
+ echo -e " "
165
+ echo -e " [FEE-SELECTION PROCESS]============================================================================================================="
166
+ echo -e " Rebalance-LND offers 3 ways to set the price-ceiling for your rebalance. Chose one of three different options below."
149
167
echo -e " "
150
168
echo -e " \tfee-factor: set b/w 0.1 and 1.0. Compare the costs against the expected income, scaled by this factor. fee-factor 1.5, routes that cost at most 150% of the expected earnings"
151
169
echo -e " \tfee-limit: enter total amount of Satoshis willing to spend per rebalance. If set, only consider rebalance transactions that cost up to the given number of satoshis."
@@ -162,10 +180,12 @@ break
162
180
done
163
181
164
182
# Fee-Value Process
165
- echo -e " ===================================================================================================================================="
166
183
echo -e " "
167
- echo -e " \t Indicate the price-ranges you want to allow as ceiling for your rebalance across all channels indicated. This is not error prone, read carefully"
168
- echo -e " \t - fee-factor:decimal set. Examples: 0.1 indicates rebalance for max 10% costs. 0.5 = 50%, 1.5 = 150%. Start low eg 0.5"
184
+ echo -e " [FEE-VALUE]========================================================================================================================="
185
+ echo -e " Economically viable pricing your rebalance-action is important!"
186
+ echo -e " Indicate the price-ranges you want to allow as ceiling for your rebalance across all channels indicated. This is not error prone, read carefully"
187
+ echo -e " "
188
+ echo -e " \t - fee-factor: decimal set. Examples: 0.1 indicates rebalance for max 10% costs. 0.5 = 50%, 1.5 = 150%. Start low eg 0.5"
169
189
echo -e " \t - fee-limit: total amount of satoshis per rebalance, eg. 30"
170
190
echo -e " \t - fee-ppm-limit: fee-rate per million satoshis. Set to 200 will pay a max of 200 satoshis for every million satoshis rebalanced"
171
191
echo -e " "
@@ -189,20 +209,52 @@ else
189
209
fi
190
210
echo " We'll go for $feevalue "
191
211
212
+ # Amount-Definition Process
213
+ echo -e " "
214
+ echo -e " [AMOUNT-SELECTION PROCESS]==========================================================================================================="
215
+ echo -e " Now lastly, let's determine the girth: Do you want the Script to take over how much to rebalance, or want to specify the size?"
216
+ echo -e " "
217
+ echo -e " \tAutomated: The script will aim for 5 steps to get your channel to 50:50 balance, or 1M on either side for channels bigger > 2M satoshis"
218
+ echo -e " \tDefined: You aim to rebalance a defined amount satoshis. It'll be divided into 5 chunks, since smaller sizes usually rebalance easier "
219
+ echo -e " "
220
+ echo -e " Please note: In case you called > more than one channel to rebalance, the second option " Defined" will be tried for ALL channels given"
221
+ echo -e " "
222
+
223
+ amountoptions=' Automated Defined'
224
+ PS3=' Select Amount Option: '
225
+
226
+ select amountoption in $amountoptions
227
+ do
228
+ echo " We'll go for $amountoption "
229
+ break
230
+ done
231
+
232
+ if [ $amountoption == ' Defined' ]
233
+ then
234
+ echo " How much do you want to $direction ? Enter the absolute amount in Satoshis, eg 1000000"
235
+ read amountvalue
236
+ else
237
+ amountvalue=' '
238
+ # break
239
+ fi
240
+
192
241
# Parse parameters from the command initiation
193
242
echo -e " "
194
- echo -e " ===================================================================================================================================="
195
- echo " Fee Attribute > $feeoption "
196
- echo " Fee Value > $feevalue "
197
- echo " Direction 👉Push or 👈Pull > $direction "
198
- echo " "
199
- echo " Channel ID 1 > $parameterJ "
200
- echo " Channel ID 2 > $parameterK "
201
- echo " Channel ID 3 > $parameterL "
202
- echo " Channel ID 4 > $parameterM "
203
- echo " Channel ID 5 > $parameterN "
204
- echo " Channel ID 6 > $parameterO "
205
- echo " Channel ID 7 > $parameterP "
243
+ echo -e " [SUMMARY]==========================================================================================================================="
244
+ echo -e " Fee Attribute > \t\t $feeoption "
245
+ echo -e " Fee Value > \t\t\t $feevalue "
246
+ echo -e " Direction 👉Push or 👈Pull > \t $direction "
247
+ echo -e " Amount-Definition > \t\t $amountoption $amountvalue "
248
+
249
+
250
+ echo -e " "
251
+ echo -e " Channel ID 1 > \t\t\t $parameterJ "
252
+ echo -e " Channel ID 2 > \t\t\t $parameterK "
253
+ echo -e " Channel ID 3 > \t\t\t $parameterL "
254
+ echo -e " Channel ID 4 > \t\t\t $parameterM "
255
+ echo -e " Channel ID 5 > \t\t\t $parameterN "
256
+ echo -e " Channel ID 6 > \t\t\t $parameterO "
257
+ echo -e " Channel ID 7 > \t\t\t $parameterP "
206
258
echo -e " ===================================================================================================================================="
207
259
echo -e " "
208
260
0 commit comments