Skip to content

Commit

Permalink
feat: rising fees notification
Browse files Browse the repository at this point in the history
  • Loading branch information
malteo committed Feb 9, 2024
1 parent 5d3c569 commit 83faae0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ COPY bitcoin-fee-notifier.nu /etc/periodic/hourly/
ARG NTFY_TOPIC
ENV NTFY_TOPIC=${NTFY_TOPIC}
ENV CHEAP_FEE 35
ENV RISING_TRIGGER 1.5
ENV NU_LOG_LEVEL DEBUG
ENTRYPOINT ["crond", "-f"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ Example:
CHEAP_FEE=10
```

### RISING_TRIGGER

The percentage (in decimal form) upper limit from the last reported fee to trigger a rising fees notification.

Defaults to `1.5`.

Example:

```
RISING_TRIGGER=1.618
```

## Usage (standalone)

```bash
Expand Down
5 changes: 5 additions & 0 deletions bitcoin-fee-notifier.nu
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ if not ($last_fee | path exists) {
let fee = (http get https://mempool.space/api/v1/fees/recommended).economyFee
let cheap = $env.CHEAP_FEE? | default 35 | into int
let last = open $last_fee | into int
let rising_trigger = $env.RISING_TRIGGER? | default 1.5 | into float

if $fee < $cheap {
if $fee < $last {
http post --headers [Title 'Cheap transaction fees!' Tags partying_face] $'https://ntfy.sh/($env.NTFY_TOPIC)' $'($fee) sat/vB'
$fee | save -f $last_fee
log debug $'Notified cheap transaction fees at ($fee) sat/vB'
} else if $fee > $last * $rising_trigger {
http post --headers [Title 'Transaction fees rising!' Tags facepalm] $'https://ntfy.sh/($env.NTFY_TOPIC)' $'($fee) sat/vB'
$fee | save -f $last_fee
log debug $'Notified transaction fees rising to ($fee) sat/vB'
} else {
log debug $'Already notified transaction fees at ($fee) sat/vB'
}
Expand Down

0 comments on commit 83faae0

Please sign in to comment.