Skip to content

Commit

Permalink
rfq: remove unused function pricesWithinBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Oct 3, 2024
1 parent 73c30e0 commit aa53ed4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 171 deletions.
35 changes: 0 additions & 35 deletions rfq/negotiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rfq

import (
"fmt"
"math"
"math/big"
"sync"
"time"
Expand All @@ -13,7 +12,6 @@ import (
"github.com/lightninglabs/taproot-assets/rfqmath"
"github.com/lightninglabs/taproot-assets/rfqmsg"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)

Expand Down Expand Up @@ -507,39 +505,6 @@ func expiryWithinBounds(expiryUnixTimestamp uint64,
return diff >= int64(minExpiryLifetime)
}

// priceWithinBounds returns true if the difference between the first price and
// the second price is within the given tolerance (in parts per million (PPM)).
//
// TODO(ffranr): Replace with FixedPoint[T].WithinTolerance.
func pricesWithinBounds(firstPrice lnwire.MilliSatoshi,
secondPrice lnwire.MilliSatoshi, tolerancePpm uint64) bool {

// Handle the case where both prices are zero.
if firstPrice == 0 && secondPrice == 0 {
return true
}

// Handle cases where either price is zero.
if firstPrice == 0 || secondPrice == 0 {
return false
}

firstP := float64(firstPrice)
secondP := float64(secondPrice)

// Calculate the absolute difference between both prices.
delta := math.Abs(firstP - secondP)

// Normalize the delta by dividing by the greater of the two prices.
normalisedDelta := delta / math.Max(firstP, secondP)

// Convert the fraction to parts per million (PPM).
deltaPpm := 1_000_000 * normalisedDelta

// Compare the difference to the tolerance.
return deltaPpm <= float64(tolerancePpm)
}

// HandleIncomingBuyAccept handles an incoming buy accept message. This method
// is called when a peer accepts a quote request from this node. The method
// checks the price and expiry time of the quote accept message. Once validation
Expand Down
136 changes: 0 additions & 136 deletions rfq/negotiator_test.go

This file was deleted.

0 comments on commit aa53ed4

Please sign in to comment.