Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sweep conf target argument for swaps #68

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
markettes marked this conversation as resolved.
Show resolved Hide resolved
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