Skip to content

Commit

Permalink
feat(Dockerfile): upgrade golang version from 1.20.4 to 1.21.4 for la…
Browse files Browse the repository at this point in the history
…test features and security updates (#68)

docs(README.md): update flags documentation to reflect recent changes and additions
feat(flags.go): increase swapPublicationOffset from 30m to 60m for more flexibility
feat(flags.go): add new flag sweepConfTarget for configurable confirmation targets
refactor(loop_provider.go): replace hardcoded SweepConfTarget with configurable value from flags
fix(loop_provider.go): remove unnecessary whitespace for cleaner code
  • Loading branch information
Jossec101 authored Jan 12, 2024
1 parent bfa36b9 commit 76ca6e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.4-alpine AS builder
FROM golang:1.21.4-alpine AS builder
WORKDIR /src/
COPY . .
RUN go get -d -v ./...
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ Usage:
liquidator [flags]
Flags:
--backoffCoefficient float Coefficient to apply to the backoff (default 0.95)
--backoffLimit float Limit coefficient of the backoff (default 0.1)
-h, --help help for liquidator
--limitFees float Limit fees for swaps e.g. 0.01 = 1% (default 0.007)
--lndconnecturis string CSV of lndconnect strings to connect to lnd(s)
--backoffCoefficient float Coefficient to apply to the backoff (default: 0.95)
--backoffLimit float Limit coefficient of the backoff (default: 0.1)
--limitFees float Limit to total Swap Fees (default 0.007 -> 0.7% Swap size)
--logFormat string Log format from: {text, json} (default "text")
--logLevel string Log level from values: {trace, debug, info, warn, error, fatal, panic} (default "info")
--loopdconnecturis string CSV of loopdconnect strings to connect to loopd(s)
--nodeguardHost string Hostname:port to connect to nodeguard
--pollingInterval string Interval to poll data (default "15s")
--retriesBeforeBackoff int Number of retries before applying backoff to the swap (default: 3)
--swapPublicationOffset string Swap publication deadline offset (Maximum time for the swap provider to publish the swap) (default "30m")
--retriesBeforeBackoff int Number of retries before applying backoff to the swap (default 3)
--swapPublicationOffset string Swap publication deadline offset (Maximum time for the swap provider to publish the swap) (default "60m")
--sweepConfTarget string Target number of confirmations for swaps, this uses bitcoin core broken estimator, procced with caution (default "400")
```
# Requirements
This project uses [just](https://github.com/casey/just) with the following recipes
Expand Down
6 changes: 5 additions & 1 deletion flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func init() {
viper.BindPFlag("nodeguardHost", rootCmd.Flags().Lookup("nodeguardHost"))

//Swap Publication Offset in minutes
rootCmd.Flags().String("swapPublicationOffset", "30m", "Swap publication deadline offset (Maximum time for the swap provider to publish the swap)")
rootCmd.Flags().String("swapPublicationOffset", "60m", "Swap publication deadline offset (Maximum time for the swap provider to publish the swap)")
viper.BindPFlag("swapPublicationOffset", rootCmd.Flags().Lookup("swapPublicationOffset"))

// Retries before applying backoff to the swap
Expand All @@ -117,6 +117,10 @@ func init() {
rootCmd.Flags().Float64("limitFees", 0.007, "Limit fees for swaps e.g. 0.01 = 1%")
viper.BindPFlag("limitFees", rootCmd.Flags().Lookup("limitFees"))

//Sweep conf
rootCmd.Flags().String("sweepConfTarget", "400", "Target number of confirmations for swaps, this uses bitcoin core broken estimator, procced with caution")
viper.BindPFlag("sweepConfTarget", rootCmd.Flags().Lookup("sweepConfTarget"))

//Now we set the global vars

pollingInterval = viper.GetDuration("pollingInterval")
Expand Down
4 changes: 2 additions & 2 deletions provider/loop_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (l *LoopProvider) RequestReverseSubmarineSwap(ctx context.Context, request

sumFees := quote.SwapFeeSat + quote.HtlcSweepFeeSat + quote.PrepayAmtSat
maximumFeesAllowed := int64(float64(request.SatsAmount) * limitFees)

if sumFees > maximumFeesAllowed {
err := fmt.Errorf("swap fees are greater than max limit fees, quote fees: %d, maximum fees allowed: %d", sumFees, maximumFeesAllowed)
log.Error(err)
Expand All @@ -272,7 +272,7 @@ func (l *LoopProvider) RequestReverseSubmarineSwap(ctx context.Context, request
MaxPrepayRoutingFee: int64(limits.maxPrepayRoutingFee),
MaxSwapRoutingFee: int64(limits.maxSwapRoutingFee),
OutgoingChanSet: request.ChannelSet,
SweepConfTarget: 3, //TODO Make this configurable
SweepConfTarget: viper.GetInt32("sweepConfTarget"),
HtlcConfirmations: 3,
//The publication deadline is maximum the offset of the swap deadline conf plus the current time
SwapPublicationDeadline: uint64(time.Now().Add(viper.GetDuration("swapPublicationOffset") * time.Minute).Unix()),
Expand Down

0 comments on commit 76ca6e9

Please sign in to comment.