Skip to content
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
9 changes: 1 addition & 8 deletions liquidity/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
23 changes: 3 additions & 20 deletions liquidity/liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 0 additions & 15 deletions liquidity/liquidity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,21 +1564,6 @@ func TestFeePercentage(t *testing.T) {
DisqualifiedPeers: noPeersDisqualified,
},
},
{
name: "prepay too high",
feePPM: 30000,
quote: &loop.LoopOutQuote{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if instead of deleting just fixing the outcome and adding a comment why this will result in a suggestion is better.

SwapFee: 75,
PrepayAmount: 300,
MinerFee: 1,
},
suggestions: &Suggestions{
DisqualifiedChans: map[lnwire.ShortChannelID]Reason{
chanID1: ReasonPrepay,
},
DisqualifiedPeers: noPeersDisqualified,
},
},
}

for _, testCase := range tests {
Expand Down
1 change: 0 additions & 1 deletion liquidity/loopout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}

Expand Down