ZmnSCPxj / clboss

Automated Core Lightning Node Manager
MIT License
213 stars 31 forks source link

feat: splicing, peerswap, and/or liquidity ads as an alternative to channel opens/closes/swaps #176

Open chrisguida opened 1 year ago

chrisguida commented 1 year ago

would be epic

ksedgwic commented 1 year ago

Can you give an example of what you mean? Which current operations can we replace?

chrisguida commented 1 year ago

Apologies for the sparse issue.

Currently CLBOSS uses Boltz to swap in and swap out liquidity. Seems we could easily replace that with splicing in some cases. It would be great not to have to rely on a centralized swapping service for off-chain/on-chain liquidity exchange, and we could potentially save a lot on fees.

Additionally, CLBOSS can only open or close channels currently, not make them larger or smaller. It would probably be a lot more efficient to adaptively increase/decrease liquidity in channels as profitability varies, rather than simply closing the channel and opening a new one.

We could probably gather much better data this way (e.g., by tesing different pricing theories in the same channel before and after a splice, to see what the effect is on our profitability).

In addition, gossip delays mean that other nodes may still try to use old channels for a period after a channel is closed; splicing could allow them to continue using channels that are simply smaller than before rather than closed.

I suppose this is more of a discussion topic than a specific feature request, but it does seem to me like CLBOSS could benefit a lot from leveraging splicing.

chrisguida commented 1 year ago

Basically, splicing allows you to have much more fine-grained control on how much exposure you have to your channel partners. Right now CLBOSS is limited to sort of a "hammer" approach: opening a channel for a more-or-less arbitrary amount (some large percentage of your on-chain tank) and keeping the channel until it's deemed unprofitable, then closing it (if closes are enabled). Splicing seems like a much more elegant tool.

ksedgwic commented 1 year ago

Is there a way to acquire inbound liquidity w/ splicing instead of using Boltz? This would be really great, but I don't see how to do it yet ...

chrisguida commented 1 year ago

Hmm, good point, I guess swapping using splicing would be limited to only swapping out, unless paired with something like liquidity ads. Which, come to think of it, would also be a great thing to incorporate in CLBOSS.

Though perhaps I'm missing something?

Seems like there should be some kind of protocol where I trustlessly pay my channel counterparty on-chain for some inbound liquidity? I believe LND can do this using BOS...

ksedgwic commented 1 year ago

Agree about liquidity ads! Seems like a natural (and powerful) extension of CLBOSS features to both offer and acquire liquidity this way.

chrisguida commented 1 year ago

By the way, LND cannot do this with BOS; I was thinking of the "dual-fund" feature where you can interactively fund a channel open with another peer who also has BOS.

However, I heard from @niftynei that the above swapping process is basically an exact description of the PeerSwap protocol. Perhaps the missing piece of the puzzle.

chrisguida commented 1 year ago

The PeerSwap docs don't mention that splicing doesn't work for inbound liqudity. This implies that it does work for inbound??

Screenshot from 2023-09-01 19-35-50

ZmnSCPxj commented 1 year ago

Please note that using a remote swap service like Boltz or Loop is superior as a method of getting inbound liquidity than liquidity ads, peerswap, OR inbound liquidity marketplaces like Magma. See: https://github.com/ZmnSCPxj-jr/sidepool/blob/master/doc/00-sidepools-are-awesome.md#the-real-solution-offchain-to-onchain-swaps

TLDR: Remote swap services must first actually have inbound liquidity to sell before the swap will work with them, and the proof of having inbound liquidity is atomic to buying inbound liquidity from a remote swap service; all other methods of selling inbound liquidity DO NOT actually need to have inbound liquidity to sell to you, meaning you could potentially buy inbound liquidity from a node that itself lacks inbound liquidity and would not be able to forward to you anyway. You would be unable to know this fact until you have already paid them for the inbound liquidity, at which point they have already taken your money. There are also no good reputation systems for this, as they can always claim that the problem is with your customers specifically not having good liquidity to them, not them having a general lack of liquidity from anyone.

niftynei commented 1 year ago

you would be unable to know this fact until you have already paid them for the inbound liquidity

iiuc you could probe the public channel of a candidate inbound sale partner for relative balances before agreeing to a contract with them; it's not as self-contained as an atomic swap contract but it's not "unable to know" merely "more difficult to know".

chrisguida commented 1 year ago

@ZmnSCPxj thanks for the heads up. I've read the link you shared and I have a few questions:

1) When you select a random node R through which to buy inbound liquidity from a swap provider S, it sounds like you must build the route to do the swap making sure to include R in your route. You didn't explicitly state this, but it seems like a requirement, correct? Then the "proof" of inbound liquidity comes in the form of the outbound liquidity you send to S to buy the on-chain funds, right?

Thanks again for your insight here; let me know if I'm missing anything :)