Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee credit feature for on-the-fly funding #660

Merged
merged 4 commits into from
Sep 26, 2024
Merged

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Jun 13, 2024

We add an optional feature that lets on-the-fly funding clients accept payments that are too small to pay the fees for an on-the-fly funding. When that happens, the payment amount is added as "fee credit" without performing an on-chain operation. Once enough fee credit has been obtained, we can initiate an on-chain operation to create a channel or a splice by paying part of the fees from our fee credit.

This feature makes more efficient use of on-chain transactions by trusting that our peer will honor our fee credit in the future. The fee credit takes precedence over other ways of paying the fees (from our channel balance or future HTLCs), which guarantees that the fee credit eventually converges to 0.

@t-bast t-bast marked this pull request as draft June 14, 2024 15:54
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch 5 times, most recently from 21d9fae to 2f5f38a Compare July 8, 2024 09:52
@t-bast t-bast marked this pull request as ready for review August 28, 2024 07:59
@t-bast t-bast requested a review from pm47 August 28, 2024 07:59
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch 4 times, most recently from 0de4be2 to 9aa22ff Compare September 6, 2024 15:34
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch 5 times, most recently from 8e8add2 to 969560e Compare September 16, 2024 08:30
We add an optional feature that lets on-the-fly funding clients accept
payments that are too small to pay the fees for an on-the-fly funding.
When that happens, the payment amount is added as "fee credit" without
performing an on-chain operation. Once enough fee credit has been
obtained, we can initiate an on-chain operation to create a channel or
a splice by paying part of the fees from our fee credit.

This feature makes more efficient use of on-chain transactions by
trusting that our peer will honor our fee credit in the future. The
fee credit takes precedence over other ways of paying the fees (from
our channel balance or future HTLCs), which guarantees that the fee
credit eventually converges to 0.
Add a parameter to our liquidity policy to limit the amount that can be
allocated to fee credit. We don't want a temporary high feerate to cause
wallet users to allocate too much funds towards their fee credit, which
they may not use later.
If our balance, combined with our fee credit, doesn't allow us to pay
the liquidity fees with the payment type we chose, we immediately abort
the splice.
@t-bast t-bast merged commit 7750d05 into master Sep 26, 2024
2 checks passed
@t-bast t-bast deleted the on-the-fly-fee-credit branch September 26, 2024 01:21
pm47 added a commit that referenced this pull request Sep 27, 2024
* enable feature FundingFeeCredit

* emit a liquidity event for each liquidity purchase

Independently of whether the purchase was triggered by an on-chain or
off-chain payment.

Also renamed `LiquidityEvents.Accepted` to `LiquidityEvents.Purchased`.

* expose serviceFee in InboundLiquidityOutgoingPayment

* add events PaymentEvents.PaymentSent
pm47 added a commit to ACINQ/phoenixd that referenced this pull request Oct 3, 2024
Adds support for liquidity-ads based protocol for on-the-fly liquidity as specified in lightning/blips#36 and lightning/blips#41, implemented respectively in ACINQ/lightning-kmp#649  and ACINQ/lightning-kmp#660.

### Lightning-kmp update

Phoenixd now uses the main branch of `lightning-kmp` (v1.8.0).

### Database update

- `LiquidityAds.Lease` is replaced by `LiquidityAds.Purchase`, so we need to update the liquidity table.
- the `receivedWith` data have been updated in lightning-kmp, and we need a new `Part.Htlc.V1` object that may contain a `LiquidityAds.FundingFee`.

With the `Lease->Purchase` change, we've updated our pattern for versioning database objects. We now have `asDb()` & `asCanonical()` mapping methods and store the type of the db object inside the json (which means we don't need the `type` column anymore, except for convenience).

---------

Co-authored-by: pm47 <[email protected]>
vincenzopalazzo pushed a commit to vincenzopalazzo/phoenixd that referenced this pull request Nov 7, 2024
Adds support for liquidity-ads based protocol for on-the-fly liquidity as specified in lightning/blips#36 and lightning/blips#41, implemented respectively in ACINQ/lightning-kmp#649  and ACINQ/lightning-kmp#660.

### Lightning-kmp update

Phoenixd now uses the main branch of `lightning-kmp` (v1.8.0).

### Database update

- `LiquidityAds.Lease` is replaced by `LiquidityAds.Purchase`, so we need to update the liquidity table.
- the `receivedWith` data have been updated in lightning-kmp, and we need a new `Part.Htlc.V1` object that may contain a `LiquidityAds.FundingFee`.

With the `Lease->Purchase` change, we've updated our pattern for versioning database objects. We now have `asDb()` & `asCanonical()` mapping methods and store the type of the db object inside the json (which means we don't need the `type` column anymore, except for convenience).

---------

Co-authored-by: pm47 <[email protected]>
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.

2 participants