# 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](https://stacker.news/items/399400): Overview, Installation, and first Peg-In
* [Part II](https://stacker.news/items/407806): Asset Creation and Configuration
* Part III (this): Advanced Topics and Peg-out

# Advanced Asset Topics

[In Part II](https://stacker.news/items/407806), we focused on issuing Assets. Now let's look at the ways you can *use* assets. 

One of the most basic usecases 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, all of this implies lots of little things to be built: We would need an accounting system to manage the points, we would need some way to issue these points to the clients, who themselves would need some a way to store and manage their points. Further, there would need to some type of middleware to handle the exchanging of points for cash. Also there is a big question of security...could development staff - either intentionally or unintentionally - wind up giving away millions in points? Sure, Stacker News could just do all this themselves using SQL, but lets suppose that since they were clever boys & girls, so they wanted to do as little of the hard work as possible. 

Liquid would make a great solution for this case. They could simple direct their users to download one of the existing Liquid wallets[^1] and use the Liquid sidechain as the "accounting system" for their asset. 


## Atomic Swaps

So our client has 1 `StackerNewsDemo-1` token in their wallet (which for our purposes is our pretend airline mile token) and he wants to exchange that for L-BTC. How do we do that?

Obviously, we could build some type of webservice that had SQL databases and nodejs files that accept Asset A and then issued Asset B once received...however as we said our StackerNews crew is smart and therefore prefers to do *less hardwork*

Luckily, due to the additional OPCODEs in Liquid, it supports atomic swaps between assets. In fact, Blockstream has a tool to simplify using it (obviously the steps we do here manually with the tool would be automated within the server / client in production).

![](2-part3-swaptool-proposal.png)

## Securities / Transfer Restricted / etc

# Pegging Out

# Discussion

## Lightning Integration

## Using Liquid with BTC / LN 

### Comparing eCash / Lightning / Liquid / BTC
|| eCash | Lightning | Liquid | BTC |
|-| ------| -------- | -------- | ---- |
|UTXO Model:| No UTXO. Bearer token | Your UTXO is in a multisig. | You own UTXO in sidechain | You own UTXO in mainchain |
|Redemption:| Depends on mint | No dependency (might require fee) | Depends on Federation | No dependecy |
|Longevity: | Mint must survive | Channels will close at somepoint | Federation must survive | UTXO forever |
|Online:| Must be online to verify eCash token | You must be online to recieve. You must stay online (or hire watchtower) to secure channel state | Offline receive | Offline receive |
|TXN Time:| Instant transactions | Instant transactions | Fixed 2 min transactions | Variable ~10 min transactions |
|Fees:| No fees | Neglible fees (msat) | "Low" fees (~200 sats) | High fees (~15,000 sats)|
|Liquidity:| No liquidity management | Must manage liquidity (in/out) | No liquidity management | No liquidity management|
|Privacy:| Mints can aggregate and assemble transaction data | Nodes could aggregate and assemble transaction data | Confidential transactions | Absolute public ledger |
|Federation: | Must vet each Mint | You choose channel partner | Known federation members | Soverign |
| Frac Reserve Possible: | Yes | No | Verifiable Issues | No |
|Likely Threat:| Debasement or Mint rug | Theft of funds while offline | Federation censorship | Losing keys / unspendable UTXO for fees
|Maturity: | 2023-2024 | 2018 | 2018 | 2009



## Building Your Own Federation

