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

[feature]: AddInvoice: allow specifying the asset invoice amount considering both the merchant and edge nodes' exchange rates or directly in sats along with an implied_fee_limit #1366

Open
ZZiigguurraatt opened this issue Feb 10, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@ZZiigguurraatt
Copy link

ZZiigguurraatt commented Feb 10, 2025

Consider the following

                     TA               sats               sats             TA
          Alice ------------- Bob ------------ Charlie --------- Dave ---------- Frank
         hungry              edge              routing           edge           merchant
         woman               node                node            node

For simplicity of this example, we'll assume bob and charlie don't charge any normal LN routing fees on their sats channels.

Alice wants to buy a candy bar from Frank. Alice and her price oracle thinks 1,000 assets = 10 sats.

Frank wants to be paid 40,000 taproot assets. Frank and his price oracle also thinks 1,000 assets = 10 sat, so he thinks the invoice should be 400 sats. Frank does an RFQ with Dave to get an invoice priced in sats. The invoice is for 440 sats because Dave needs to make some profit off of the deal and he his price oracle think 909 asset=10sat.

Frank gives the invoice to Alice, but she's like, what, that is way too high of a price for me, I think that is 44,000 assets, I'll go somewhere else!! Alice does not want to pay for the "implied fees" of 40 sat or 4,000 assets that dave is collecting on her to forward a payment on Frank.

The "implied fees" here from Frank's point of view are

 = frank_perceived_asset_market_equivalent_amount*(1/Dave_SellRate-1/Frank_BuyRate)
 = 40,000 asset*(1/(90.9 asset/sat)-/(100 asset/sat))
~= 40 sat = 40 sat * Frank_Buy_Rate = 40 sat * (100 asset/sat) = 4,000 asset

.

On the other hand, Frank could reduce the amount that he requests to 36,500 assets. That would then result in an invoice of 401 sats. At 401 sats, alice would think she needs to send 40,100 assets. She's would be willing to send that and Frank would get the business. In this case, Frank is indirectly paying the "implied fees" because he was forced to reduce the amount that he is invoicing for.

So, as a receiver of taproot assets, Frank needs to reduce his price in order to deal with the profit Dave needs to make, otherwise he is going to loose customers.

We need a simpler way to invoke AddInvoice such that Frank can input perceived_asset_market_equivalent_amount, which is the amount of assets he thinks his customer will believe the sats in the invoice are worth based on the buy rate Frank gets from his price oracle. The existing asset_amount that is currently input into AddInvoice can then be computed as follows:

asset_amount=perceived_asset_market_equivalent_amount*(Dave_SellRate/Frank_BuyRate)

Alternatively, we should be able to specify the amount in AddInvoice in terms of sats (let's use value since that is what LND's AddInvoice already uses) and have the asset_amount be computed as follows:

asset_amount=value*Dave_SellRate

When invoking AddInvoice, Frank does not yet know what Dave's sell rate is yet. So, we also need to be able to put some implied_fee_limit on these new options. The implied_fee_limit limits the "implied fees" that can be collected. An error will be returned and no invoice generated if Frank's buy rate and Dave's sell rate are too far apart. We should be able to specify this implied_fee_limit in terms of percent of frank_perceived_asset_market_equivalent_amount, sats, or assets.

Note: we do have the option experimental.rfq.acceptpricedeviationppm (

; The default price deviation inparts per million that is accepted by
; the RFQ negotiator.
; Example: 50,000 ppm => price deviation is set to 5% .
; experimental.rfq.acceptpricedeviationppm=50000
), but we can't set that on a per invoice basis.

@ZZiigguurraatt ZZiigguurraatt added the enhancement New feature or request label Feb 10, 2025
@ZZiigguurraatt ZZiigguurraatt changed the title [feature]: AddInvoice: allow specifying the asset invoice amount using the merchant node's buy exchange rate or sats along with an implied_fee_limit [feature]: AddInvoice: allow specifying the asset invoice amount using the merchant node's buy exchange rate or directly sats along with an implied_fee_limit Feb 10, 2025
@ZZiigguurraatt ZZiigguurraatt changed the title [feature]: AddInvoice: allow specifying the asset invoice amount using the merchant node's buy exchange rate or directly sats along with an implied_fee_limit [feature]: AddInvoice: allow specifying the asset invoice amount using the merchant node's buy exchange rate or directly in sats along with an implied_fee_limit Feb 10, 2025
@ZZiigguurraatt ZZiigguurraatt changed the title [feature]: AddInvoice: allow specifying the asset invoice amount using the merchant node's buy exchange rate or directly in sats along with an implied_fee_limit [feature]: AddInvoice: allow specifying the asset invoice amount considering both the merchant and edge nodes' exchange rates or directly in sats along with an implied_fee_limit Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant