@@ -10,6 +10,10 @@ if [[ -z "$ENV_FILE" ]]; then
1010 exit 1
1111fi
1212
13+ function send_proof_background() {
14+ ./alerts/sender_with_alert.sh " $ENV_FILE " &
15+ }
16+
1317# Fetches the current ETH gas price
1418function fetch_gas_price() {
1519 gas_price=$( cast gas-price --rpc-url $RPC_URL )
@@ -23,8 +27,8 @@ function fetch_gas_price() {
2327
2428source " $ENV_FILE "
2529
26- # Each elapsed interval lasts for 30 minutes
27- sleep_time=1800
30+ # Each elapsed interval lasts for 5 minutes
31+ sleep_time=300
2832elapsed_intervals=0
2933
3034./alerts/sender_with_alert.sh " $ENV_FILE "
@@ -45,29 +49,47 @@ while true; do
4549 echo " Current gas price: $current_gas_price wei"
4650
4751 # In case current and gas price meet the criteria, send a proof and reset counter
48- if { [ $elapsed_intervals -ge 10 ] && [ $elapsed_intervals -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then
49- # Between 10 and 14 elapsed intervals (5 to 7 hours), if gas price is below 2 gwei, send a proof
52+ if { [ $elapsed_intervals -ge 1 ] && [ $elapsed_intervals -lt 3 ] && [ $current_gas_price -lt 1500000000 ]; }; then
53+ # Between 1 and 3 elapsed intervals (5 to 15 minutes), if gas price is below 1.5 gwei, send a proof
54+ message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
55+ echo " $message "
56+ send_proof_background
57+ elapsed_intervals=0
58+ elif { [ $elapsed_intervals -ge 3 ] && [ $elapsed_intervals -lt 6 ] && [ $current_gas_price -lt 4500000000 ]; }; then
59+ # Between 3 and 6 elapsed intervals (15 to 30 minutes), if gas price is below 4.5 gwei, send a proof
60+ message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
61+ echo " $message "
62+ send_proof_background
63+ elapsed_intervals=0
64+ elif { [ $elapsed_intervals -ge 6 ] && [ $elapsed_intervals -lt 12 ] && [ $current_gas_price -lt 9000000000 ]; }; then
65+ # Between 6 and 12 elapsed intervals (30 minutes to 1 hour), if gas price is below 9 gwei, send a proof
66+ message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
67+ echo " $message "
68+ send_proof_background
69+ elapsed_intervals=0
70+ elif { [ $elapsed_intervals -ge 12 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 24000000000 ]; }; then
71+ # Between 12 and 24 elapsed intervals (1 to 2 hours), if gas price is below 24 gwei, send a proof
5072 message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5173 echo " $message "
52- ./alerts/sender_with_alert.sh " $ENV_FILE "
74+ send_proof_background
5375 elapsed_intervals=0
54- elif { [ $elapsed_intervals -ge 14 ] && [ $elapsed_intervals -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then
55- # Between 14 and 16 elapsed intervals (7 to 8 hours), if gas price is below 5 gwei, send a proof
76+ elif { [ $elapsed_intervals -ge 24 ] && [ $elapsed_intervals -lt 48 ] && [ $current_gas_price -lt 48000000000 ]; }; then
77+ # Between 24 and 48 elapsed intervals (2 to 4 hours), if gas price is below 48 gwei, send a proof
5678 message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5779 echo " $message "
58- ./alerts/sender_with_alert.sh " $ENV_FILE "
80+ send_proof_background
5981 elapsed_intervals=0
60- elif { [ $elapsed_intervals -ge 16 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then
61- # Between 16 and 24 elapsed intervals (8 to 12 hours), if gas price is below 15 gwei, send a proof
82+ elif { [ $elapsed_intervals -ge 48 ] && [ $elapsed_intervals -lt 96 ] && [ $current_gas_price -lt 96000000000 ]; }; then
83+ # Between 48 and 96 elapsed intervals (4 to 8 hours), if gas price is below 96 gwei, send a proof
6284 message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6385 echo " $message "
64- ./alerts/sender_with_alert.sh " $ENV_FILE "
86+ send_proof_background
6587 elapsed_intervals=0
66- elif { [ $elapsed_intervals -ge 50 ]; }; then
67- # After 50 elapsed intervals (25 hours) send a proof
88+ elif { [ $elapsed_intervals -ge 96 ] && [ $current_gas_price -lt 192000000000 ]; }; then
89+ # After 96 elapsed intervals (8 hours), if gas price is below 192 gwei, send a proof
6890 message=" Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6991 echo " $message "
70- ./alerts/sender_with_alert.sh " $ENV_FILE "
92+ send_proof_background
7193 elapsed_intervals=0
7294 fi
7395
0 commit comments