Skip to content

Conversation

@carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Nov 15, 2021

This PR does some preliminary work for adding autoloopin support. Primarily adding a swap type to our liquidity rules, and implementing some of the fees + budgeting plumbing we need.

Pull Request Checklist

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

@carlaKC carlaKC mentioned this pull request Nov 15, 2021
1 task
@carlaKC carlaKC requested review from arshbot and bhandras November 15, 2021 13:42
@carlaKC
Copy link
Contributor Author

carlaKC commented Nov 15, 2021

Split up #419 into 2 parts for easier review. Follow up PR is up (just one unit test needs fixing) for reference of how this will be used.

I intend to merge them at the same time, since this doesn't really add much functionality, just easier to split early IMO.

Copy link
Contributor

@arshbot arshbot left a comment

Choose a reason for hiding this comment

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

A necessary PR, love the inclusion of loop in's to the accounting stuff, that'll be useful to a lot of people. Left some minor nits and context qs

@carlaKC
Copy link
Contributor Author

carlaKC commented Nov 29, 2021

@bhandras PTAL!

@carlaKC carlaKC requested a review from arshbot November 29, 2021 08:38
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 💯

switch rule.Type {
case swap.TypeOut:
builder = newLoopOutBuilder(m.cfg)
restrictions = outRestrictions
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd keep the incoming outRestrictions arg with it's old name (restrictions) instead.

@carlaKC carlaKC force-pushed the 419-swaptype branch 2 times, most recently from 9925339 to 37ce888 Compare November 30, 2021 11:17
The current wording in this function is very specific to loop out.
In this commit, we refactor to use `target` and `reserve` rather
than inbound and outbound so that it can be used more generically.
In preparation for adding loop in swaps, we relate liquidity rules
to a specific type of swap that we want to dispatch. This allows us
to use a single rule format for multiple swap types.
In preparation of supporting multiple swap types, we move our swap
builder into a single place, so that we can check our `maySwap`
restriction per-swap (since we'll now have different checks for
different swap types.

To save ourselves from making multiple calls to the loop server for
the restrictions placed on each swap type, we still pass a single
set of restrictions in.
Add an implementation of our swap interface which can be used for
loop in, and fee estimation. For fee estimation, we always want to
calculate worst case loop in fees, so that autoloop never goes over
its budget. However, for loop in we can't estimate how much a
timeout would cost, because we must sweep the output (can't set
a limit like loop out), and fee estimation in a few hundred blocks
(when we'd sweep the timeout) is totally unreliable.

Instead, we use a high fee rate as our best-effort fee rate for
the future. We can also be confident that that loop in swaps will
succeed, since once the htlc is locked in, all that is required
is for the server to sweep.
Copy link
Contributor

@arshbot arshbot left a comment

Choose a reason for hiding this comment

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

LGTM!!

@carlaKC carlaKC merged commit 2e6adea into lightninglabs:master Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants