lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
439 stars 106 forks source link

[feature]: Automatic asset/btc sloshing to battle premature channel exchaustion #935

Open GeorgeTsagk opened 3 weeks ago

GeorgeTsagk commented 3 weeks ago

Problem

A tap channel may reach a state where assets are available on the balances of both peers, but the btc balance on one side is depleted. This will prevent the depleted side from sending assets over the channel.

Solution

To avoid this, we can consider adding an automatic asset-to-btc sloshing. This is basically an automated asset-sell procedure which aims to "burn" some of the asset balance in the channel to gain some btc balance, which will allow asset payments to go through.

Since our btc channel size is relatively small, we can consider a default target of 10%, which is the percentage of the btc capacity that we'll try to automatically acquire on our side by selling assets. This should also be configurable.

Example

Alice and Bob have a beefbux channel Beefbux capacity: 5000 units Btc capacity: 100k sats

Let's assume 1 beefbux = 1000 sats

The asset balances are Alice: 2500 units / Bob: 2500 units The btc balances are Alice: 0sats / Bob: 100k sats (Alice can make 0 payments)

Alice will automatically sell some assets to acquire (default: 10%) 10k sats in order to continue being able to make payments. Alice negotiates a quote with Bob, then sends 5 beefbux over the channel in exchange for 10k sats.

Result: The asset balances are: Alice: 2495 units / Bob: 2505 units The btc balances are: Alice: 10k sats / Bob: 90k sats (Alice can make ~30 payments)