loop icon indicating copy to clipboard operation
loop copied to clipboard

loopout: re-target sweep's feerate every block

Open starius opened this issue 1 year ago • 1 comments
trafficstars

Add type loopOutSweepFeerateProvider which determines confTarget based on distance to swap expiration, then determines feerate and fee using. Fee rate is plugged into sweepbatcher using WithCustomFeeRate.

When determining confTarget, there are few adjustments over raw distance to cltv_expiry:

  • make sure confTarget is positive (if the swap has expired, raw distance is negative)
  • If confTarget is less than or equal to DefaultSweepConfTargetDelta (10), cap it with urgentSweepConfTarget and apply fee factor (1.1x).

Also, if feerate is less than floor (1 sat/vbyte), then the floor is used.

DefaultSweepConfTargetDelta was decreased from 18 to 10.

Every block 100 sats/kw fee bump is disabled. Sweepbatcher re-targets feerate every block according to current mempool conditions and the number of blocks until expiry.

Added tests for loopOutSweepFeerateProvider simulating various conditions.

Pull Request Checklist

  • [ ] Update release_notes.md if your PR contains major features, breaking changes or bugfixes

starius avatar Oct 19 '24 04:10 starius