Skip to content

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

Merged
t-bast merged 4 commits intomasterfrom
on-the-fly-fee-credit
Sep 26, 2024
Merged

Add fee credit feature for on-the-fly funding#660
t-bast merged 4 commits intomasterfrom
on-the-fly-fee-credit

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 force-pushed the on-the-fly-fee-credit branch from 2f5f38a to e6f9236 Compare July 9, 2024 15:42
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch from e6f9236 to 850f884 Compare July 17, 2024 11:39
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch from 850f884 to 40dd1dd Compare July 19, 2024 08:56
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch from 40dd1dd to a7caee0 Compare August 28, 2024 07:59
@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
@t-bast t-bast force-pushed the on-the-fly-fee-credit branch from 969560e to 2b3062f Compare September 18, 2024 16:21
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 force-pushed the on-the-fly-fee-credit branch from 5d21e08 to 9faa2dd Compare September 25, 2024 01:19
@t-bast t-bast merged commit 7750d05 into master Sep 26, 2024
@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 <pm.padiou@gmail.com>
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 <pm.padiou@gmail.com>
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