DeepDive into Liquid: Part III - Advanced Asset Functions, Peg-Out, Discussion

This is a multipart DeepDive that will focus on the Liquid Sidechain. It will be released in 3 Parts:
  • Part I: Overview, Installation, and first Peg-In
  • Part II: Asset Creation and Configuration
  • Part III (this): Advanced Topics and Peg-out

Advanced Asset Topics

In Part II, we focused on issuing Assets. Now let's look at the ways you can use assets.
One of the most basic use-cases for a custom issued asset is to exchange it for something else. For purposes of discussion, let's assume that a company - say StackerNews Airline - wants to issue their clients "Air Miles" for each flight they take. The idea is clients will accrue these points and then be able to exchange them for either discounts off future flights or direct cash (ie. USD / BTC).
If we start thinking like a developer for second, this implies we must build many things:
  • An accounting system to manage the points
  • A way to issue these points to the clients, who themselves would need some a way to store and manage their points
  • Middleware to handle the exchanging of points for cash
  • Security? How do we secure this? How to reduce fraud as much as possible?
Sure, Stacker News could just do all this themselves using SQL, but lets assume that since they were clever boys & girls, they wanted to do as little of the hard work as possible.

Atomic Swaps

Liquid would make a great solution for this case. They could direct their users to download one of the existing Liquid wallets1 and use the Liquid sidechain as the "accounting system" for their asset.
Suppose our Customer has earned 1 SND token (which for our purposes is our pretend airline mile token) and now he wants to exchange that for L-BTC. How do we do that? Luckily for us, Atomic Swaps2 are supported. In fact, Blockstream has a tool to simplify using it3.
To do a swap we will need another wallet, as you can't swap between the same wallet (technically you can use the same node and use 2 different wallets on that node4). In my case, I have 2 nodes each running their own elementsd server (Umbrel and my desktop). So I will use those, but you can use a single node by setting up multiple wallets and using distinct URL connect strings for each.
Before we start, let's look at state of our 2 wallets:
#Node1 - StackerNews Airline, Inc. "balance": { "bitcoin": 0.00131755, "3e62af3c80c56ab6fec3d1e5646637152afebaf2a86ace075bbb7a88702e1fe5": 8.00000000 } #Node2 - The Customer "balance": { "bitcoin": 0.00010623, "3e62af3c80c56ab6fec3d1e5646637152afebaf2a86ace075bbb7a88702e1fe5": 1.00000000 },
The Blockstream Liquid Swap tool mentioned previously works both in CLI and GUI mode. So for this example we will use CLI for Node1 and GUI for Node 2. The swap offer proposal is: StackerNews Airline (Node 1) is willing to accept a SND token and return to the client 2,300 sats (approx $1 USD currently). So Node1 makes the following proposal:
# Node 1 - StackerNews Airline, Inc. $ liquidswap-cli -u http://$E_RPCUSER:$E_RPCPASS@localhost:7041 propose -o proposal.txt 3e62af3c80c56ab6fec3d1e5646637152afebaf2a86ace075bbb7a88702e1fe5 1 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d 0.000023
This file was exported to proposal.txt and transferred to Node2 (the customer), which was then inspected:
We can see that this proposal matches our expectation (1 SND token in exchange for .000023 L-BTC). So Node2 accepts the proposal:
The export accepted.txt file is transferred back to Node1 where it is finalized and sent.
# Node 1 - StackerNews Airline, Inc. $ liquidswap-cli -u http://$E_RPCUSER:$E_RPCPASS@localhost:7041 finalize accepted.txt -s { "broadcast": true, "txid": "e427ff20ee93b5c9fef74031492357f3fcb535ec834f2035918008d3de406808" }
Now lets review the state our wallets post swap:
#Node1 - StackerNews Airline, Inc. "balance": { "bitcoin": 0.00129180, "3e62af3c80c56ab6fec3d1e5646637152afebaf2a86ace075bbb7a88702e1fe5": 9.00000000 } #Node2 - The Customer "balance": { "bitcoin": 0.00012656 },
SWAP SUMMARYNode 1 (Stacker News)Node 2 (The Customer)
Pre-Swap: SND81
Post-Swap: SND90
Pre-Swap: L-BTC131755 sat10623 sat
Post-Swap: L-BTC129180 sat12656 sat
TOTAL FEES PAID275 sat267 sat
(NOTE: Obviously the workflow here is a little clunky with the back-and-forth Proposal/Accept/Finalize routine, but I wanted the steps to be transparent. In a production case this would be built into the service and client app such that the proposal and acceptance strings were automatically transferred between the parties.)

Securities / Transfer Restricted / etc

Liquid supports more advanced features than just Swaps. These features involve the use of AMP (Asset Management Platform), which is an API that allows users to issue and manage digital assets on the Liquid Network.
Here are some of the features AMP enables:
Asset TypeDescription
Tracked AssetMovement of assets are tracked by AMP. Even though the movements of the Asset are secured within Confidential Transactions (and thus private on the chain), the issuer can see. Ownership can be queried via point-in-time.
Transfer Restricted AssetIn addition to all the above features, once an asset is issued to a user, they are restricted from transferring it without specific approval from Issuer. Asset transfers are restricted based on user Categories. So for example you could create a Category of user named Stacker News User and restrict transfer of these assets only among that group
By using one of the above concepts, this means AMP can be used in the following use-cases:
  • Asset Holder Registry - Since AMP is notified of transfers, so it makes it possible for the Issuer to always know "who has what". Thus, although everything is confidential on the public blockchain (and even among the asset holders), the Issuer can still have visibility into this.
  • Share / Ownership Vetting - Because point-in-time moves can be queried, its possible for the Issuer to calculate "how long has User A owned this asset". This enables concepts like "share vetting" (eg. you can only sell your shares after holding for 365 days)
  • Paying Dividends - Since you can calculate point-in-time ownership, this makes it possible to use these assets to pay dividends (say for instance your company was to pay .01 BTC in dividends this month, and you calculated that User A held a share for 10 days and User B for 20 days. Thus, you could pay User A .0033 L-BTC and User B .0066 L-BTC)
A full demo of the security features would require their own DeepDive (hint hint). If you would like to read more or see tutorials you can visit Liquid docs website

Lightning Integration

What if you have no interest in issuing assets on Liquid, can it still be useful?
Yes. The integration of Liquid with Lightning is a hot topic these days. There are multiple different services using this approach as a way to reduce fees for channel management. This approach is what the new breed of wallets from Blockstream Green and AQUA are doing. They are seemlessly combining Liquid-BTC-LN into a unified solution.
A summary of the pain points in setting up LN channels currently are:
  • High fees to open / close
  • High fees then force larger minimums for open / close
  • Higher channel sizes then increases risk in hot wallet
Looking at this with regard to current fees illustrates the problem pretty clearly.
Channel SizeTotal Fee (sats)Effective Cost-Basis
BTC10,000 sat~ 12,500 sat> 100% (NOT POSSIBLE)
20,000 sat~ 12,500 sat62.5%
50,000 sat~ 12,500 sat25%
100,000 sat~ 12,500 sat12.5%
200,000 sat~ 12,500 sat6.25%
500,000 sat~ 12,500 sat2.5%
By using Liquid we can reduce these fees drastically:
Channel SizeTotal Fee (sats)Effective Cost-Basis
L-BTC10,000 sat~ 158 sat1.5%
20,000 sat~ 168 sat0.8%
50,000 sat~ 198 sat0.4%
100,000 sat~ 248 sat0.2%
200,000 sat~ 348 sat0.1%
500,000 sat~ 648 sat0.1%
You can see that it is much cheaper to use L-BTC. In fact its so cheap that its fine to open 25,000 sat channels...thus keeping our hot-wallet exposure risk quite low. (The above was calculated using boltz.exchange)
BTCSessions did a great video/review of how to use Liquid as a way to very cheaply manage LN channels. Check it out, because its a great review!

Pegging Out

There are a few different solutions for peg-out, sadly all require a 3rd party, however there are many non-kyc / atomic-swap options.
  • Use a CEX (Bitfinex, Bull Bitcoin, Btcturk, BTSE)
  • Bisq (defi)
  • TDEX (defi)
  • sideswap.io (atomic swap)
  • boltz (if you want to go from Liquid to LN)
  • Use a wallet that integrates to one of the above (AQUA)
For my case, I want to go from Liquid -> BTC, so I will use sideswap.io as a demo.
$ sudo ~/scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS -named sendtoaddress address="VJLGBLED..." amount=0.0011 fee_rate=0.1 assetlabel="bitcoin" 1bf3623924328b22e7b2ae1d7a9fd8bc2879d4cacabd9ba7e2fe0299fe26301e
Total cost was about 5500 sats for the peg-out (obviously I waited until it was very cheap). Of that, 5150 sats on BTC layer / 246 on Liquid / 110 sats for sideswap.io service

Final Discussion and Ideas

Each part of the Bitcoin ecosystem has its strengths and weaknesses, and often they overlap in rather confusing ways. I think it would be helpful to compare the various major initiatives. This is NOT about proclaiming one is better than the other, as you can see they each have their own strengths:

Comparing eCash / Lightning / Liquid / BTC

Fedimint / eCashLightningLiquidBTC
UTXO Model:No UTXO. Bearer tokenYour UTXO is in a multisig.You own UTXO in sidechainYou own UTXO in mainchain
Redemption:Depends on mintNo dependency (but requires fee)Depends on 3rd partyNo dependency
Self-Custody Online Req:Must be online to verify eCash tokenYou must be online to receive. You must stay online (or hire watchtower) to secure channel stateOffline receiveOffline receive
TXN Time:Instant transactionsInstant transactionsFixed 2 min transactionsVariable ~10 min transactions
Fees:No feesNegligible fees (msat)"Low" fees (~200 sats)High fees (~12,500 sats)
Liquidity:No liquidity managementMust manage liquidity (in/out)No liquidity managementNo liquidity management
Privacy:Mints can aggregate and assemble transaction dataNodes could aggregate and assemble transaction dataConfidential transactionsPublic ledger
Counter-Party Risk:Must vet each MintYou choose channel partnerKnown federation membersSovereign
Frac Reserve Possible:YesNoVerifiable IssuesNo
Self-Custody Options:eCash walletSingle Sig / Hot WalletSingle Sig / Multi Sig / Hot Wallet / Cold Wallet / Hardware WalletSingle Sig / Multi Sig / Hot Wallet / Cold Wallet / Hardware Wallet
TXN Value Size:Tied to LN size, but theoretically unlimitedTypical is < 25,000,000 satUnlimitedUnlimited
Ideal Exposure Time:daysweeksmonthsyears (forever)
Likely Threat:Debasement or Mint rugLoss of funds while offlineFederation censorshipLosing keys / non-spendable UTXO for fees
Maturity:2023-2024201820182009

Building Your Own Federation

One of the biggest issues facing Liquid users is needing to trust the Federation members5. One of the reasons why projects like Fedimint has gained in popularity is the idea of community-run mints. What if such a thing were possible with Liquid?
Well it is in theory. Elements can be used to create your own sidechain.
A brief sidebar about the name: Elements is the name node software and Liquid is the name of the chain. I mention this because its clear that Blockstream envisions a separation between the specific network and the software that runs it. Point being, you could create your own sidechain using Elements (maybe Plasma, in keeping with the elemental names?)
The basic process for creating your own sidechain would be:
  • Install elements
  • Wipe out sidechain data files
  • Decide on node discovery ports and search methods (modify node seed list and ports in config)
  • Set your sidechain name in config file (replace -chain=liquidv1 option with custom name)6
  • Set your own n-of-m block signing method and set this config files 7
  • Set your own n-of-m Peg-in script and set this in config file 8
  • Set initialfreecoins to 0 in config file
  • Set defaultpeggedassetname if you want it to be something other than bitcoin
  • Set initialreissuancetokens to non-zero so you can issue default assets as peg-ins happen
  • Provide config options to connect to BTC node to watch for pegins
In theory, you should now have your own federation on your very own sidechain.

Final Questions and Thoughts

  • Liquid is a good testing ground for new OPCODEs being considered for inclusion into BTC. Liquid allows these changes to be real-world tested before they make it into BTC. For example many of the advanced OPCODEs that are argued for inclusion into BTC for Covenants / Vaults already exist in Liquid9. This transforms Liquid into being something of a "Beta-test" chain for BTC.
  • Given the above, proponents of Covenants could use this to help make their case for inclusion into mainchain BTC. The current debate has stalled in a chicken-egg style standoff. One side is saying: Show us real world use-cases of this solving problems and the other responding we first need the OPCODEs to build these things. A potential solution is for Covenant proponents to go build their use-cases on Liquid.
  • Could Fedimints / eCash mints find ways to utilize custom sidechains based on Elements as a way to prove to users that they are not debasing eCash tokens via Frac Reserve? (record eCash issuance as asset issuances on federated sidechain?)
  • The community could spin up its own Federated version of Liquid!
  • On Federation Trusting. The most hotly debated topic around Liquid is can we trust the Federation to not censure us? I think these are reasonable concerns (but largely overblown).
    • The group Liquid Members includes some of the most traditionally pro-Bitcoin groups.
    • Has there ever been a documented case of censorship in its 6+ year existence?
    • Given Confidential Transactions, it seems to be fairly trivial to bypass any censorship attempts. Remember, not even Federation Members can know what is being transacted, nor what is held in any individual address.
    • The more swap services like boltz / sidewap are used, the more pressure it places on the federation to keep behaving
    • If all else fails, the community can create their own version of Liquid

Footnotes

  1. BlockStream Green, AQUA, Anser (web wallet), Specter, Marina (web wallet)
  2. Atomic Swaps allow parties to exchange different tokens directly without the need for a 3rd party, eliminating most of the risk of fraud and counterparty default.In fact, Blockstream has a tool to simplify using it.
  3. Please git clone the repo and don't rely on the pre-compiled downloads in repo (they are out of date from source)
  4. You can specify to individual wallets in the swap-tool URL connect string by using the http://user:password@localhost:7041/wallet/walletname syntax
  5. Its worth noting that the Liquid Federation members - as a group - tends to be a collection the most pro-bitcoin focused companies in the ecosystem.
  6. Liquid has enabled OP_CAT, OP_CHECKSIGFROMSTACK (CSFS), OP_INSPECTCURRENTINPUT, OP_INSPECTINPUT, OP_INSPECTOUTPUT, OP_TAPTWEAK, OP_MUL64, OP_DIV64, OP_SCALARADD, and OP_SCALARMUL
this territory is moderated
Great trilogy!
I learned a lot.
I use green and Aqua and Jade
reply
5 sats \ 2 replies \ @OT 7 Feb
Why would someone open a liquid-LN channel?
reply
121 sats \ 1 reply \ @freetx OP 7 Feb
Its a confusing topic! It is technically possible to open a LN channel via Core Lightning. That would enable you to send L-BTC (and assets like USDt) via Lightning.
However in most cases whats happening is that service providers are offering swaps to/from Liquid via Lightning.
This has some big benefits. Suppose for example you built up a stash of 500,000 sats on LN and you wanted to take some of it off to mainchain. Well you could "swap out" but you may be paying very high fees...for instance if you wanted to take 200,000 sats out of LN, you may pay ~5% in fees to accomplish that (depending on fees of course). Whereas using Liquid you could cash out much cheaper (ie. LN -> Liquid).
The whole idea is using Liquid sort of a "buffer" layer....between LN and BTC. This is what wallets like AQUA are doing for you automatically.
reply
I love the convenience of Aqua
reply