diff --git a/liquidity/fees.go b/liquidity/fees.go index f8e575d..36a437a 100644 --- a/liquidity/fees.go +++ b/liquidity/fees.go @@ -329,13 +329,6 @@ func (f *FeePortion) loopOutLimits(swapAmt btcutil.Amount, return newReasonError(ReasonSwapFee) } - if quote.PrepayAmount > feeLimit { - log.Debugf("prepay amount: %v greater than fee limit: %v, at "+ - "%v ppm", quote.PrepayAmount, feeLimit, f.PartsPerMillion) - - return newReasonError(ReasonPrepay) - } - // If our miner and swap fee equal our limit, we will have nothing left // for off-chain fees, so we fail out early. if minerFee+quote.SwapFee >= feeLimit { @@ -351,7 +344,7 @@ func (f *FeePortion) loopOutLimits(swapAmt btcutil.Amount, // Calculate the worst case fees that we could pay for this swap, // ensuring that we are within our fee limit even if the swap fails. fees := worstCaseOutFees( - prepay, route, quote.SwapFee, miner, quote.PrepayAmount, + prepay, route, quote.SwapFee, miner, ) if fees > feeLimit { diff --git a/liquidity/liquidity.go b/liquidity/liquidity.go index 5b47826..e2b9766 100644 --- a/liquidity/liquidity.go +++ b/liquidity/liquidity.go @@ -845,19 +845,10 @@ func (m *Manager) getSwapRestrictions(ctx context.Context, swapType swap.Type) ( // the prepay because they failed to sweep the on chain htlc. This is unlikely, // because we expect clients to be online to sweep, but we want to account for // every outcome so we include it. -func worstCaseOutFees(prepayRouting, swapRouting, swapFee, minerFee, - prepayAmount btcutil.Amount) btcutil.Amount { +func worstCaseOutFees(prepayRouting, swapRouting, swapFee, + minerFee btcutil.Amount) btcutil.Amount { - var ( - successFees = prepayRouting + minerFee + swapFee + swapRouting - noShowFees = prepayRouting + prepayAmount - ) - - if noShowFees > successFees { - return noShowFees - } - - return successFees + return prepayRouting + minerFee + swapFee + swapRouting } // existingAutoLoopSummary provides a summary of the existing autoloops which @@ -910,19 +901,11 @@ func (m *Manager) checkExistingAutoLoops(ctx context.Context, if out.State().State.Type() == loopdb.StateTypePending { summary.inFlightCount++ - prepay, err := m.cfg.Lnd.Client.DecodePaymentRequest( - ctx, out.Contract.PrepayInvoice, - ) - if err != nil { - return nil, err - } - summary.pendingFees += worstCaseOutFees( out.Contract.MaxPrepayRoutingFee, out.Contract.MaxSwapRoutingFee, out.Contract.MaxSwapFee, out.Contract.MaxMinerFee, - mSatToSatoshis(prepay.Value), ) } else if out.LastUpdateTime().After( m.params.AutoloopBudgetLastRefresh, diff --git a/liquidity/liquidity_test.go b/liquidity/liquidity_test.go index af8819b..f3d3a9d 100644 --- a/liquidity/liquidity_test.go +++ b/liquidity/liquidity_test.go @@ -1564,21 +1564,6 @@ func TestFeePercentage(t *testing.T) { DisqualifiedPeers: noPeersDisqualified, }, }, - { - name: "prepay too high", - feePPM: 30000, - quote: &loop.LoopOutQuote{ - SwapFee: 75, - PrepayAmount: 300, - MinerFee: 1, - }, - suggestions: &Suggestions{ - DisqualifiedChans: map[lnwire.ShortChannelID]Reason{ - chanID1: ReasonPrepay, - }, - DisqualifiedPeers: noPeersDisqualified, - }, - }, } for _, testCase := range tests { diff --git a/liquidity/loopout.go b/liquidity/loopout.go index 13b2ee6..17758e7 100644 --- a/liquidity/loopout.go +++ b/liquidity/loopout.go @@ -28,7 +28,6 @@ func (l *loopOutSwapSuggestion) fees() btcutil.Amount { return worstCaseOutFees( l.OutRequest.MaxPrepayRoutingFee, l.OutRequest.MaxSwapRoutingFee, l.OutRequest.MaxSwapFee, l.OutRequest.MaxMinerFee, - l.OutRequest.MaxPrepayAmount, ) }