Replies: 9 comments 19 replies
-
With needing an off-chain communication method being a common downside for the L1 scenarios - wouldn't IOTA Streams be the communication method of choice for these scenarios? |
Beta Was this translation helpful? Give feedback.
-
What's the reason of having to specify Bob's address? You can specify the token you want as the condition and anyone can unlock the UTXO. She creates a UTXO that anyone can consume. Someone consumes Alices's UTXO with 20 IOTA tokens which would go to Alice's address and they'd get 10 AliceTokens. This would happen atomically (either the swap fully happened or it didn't). Race condition can happen (multiple parties want to consume the same UTXO), but under OTV (Multiverse) there would always exist a winner. This allows for a L1 DEX to be formed without any communication. Parties can use a plugin to query the Tangle for UTXO that can be consumed and an efficient market could be formed. This would all be trustless and feeless. |
Beta Was this translation helpful? Give feedback.
-
Another option would be to implement an AMM style liquidity pool on L1 in the form of an output type. This would most probably be the most flexible and powerful option as it would ensure the ability to "always" find a trading partner. |
Beta Was this translation helpful? Give feedback.
-
I would like to reopen this discussion with particular reference to Section 6.2 "Open Swap with L1 Outputs." In fact, I think that the L2 technology is now widely developed and therefore there is no conflict with an atomic swap functionality on L1. I would like to propose only one change to the Targeted Swap Block: it must be possible to specify more than one output address. This is one possible use case:
In parallel Alice wants to do the reverse operation, so she enters a transaction that:
The transaction is confirmed, so the address ALICEADD1 contains N tokens T1, address BOBADD1 contains M tokens T2, and the address INFOADD contains K tokens T3 The transaction is deterministic, i.e., it is confirmed if the amounts and the destination address given by Alice is BOBADD1, and the transaction is entered within the time limit given by BOB. Conflict Compatibility with L2 How does Alice know that BOB has entered a transaction of her interest? Another interesting use case is the NFT exchange.
The information that the NFT is for sale will be posted on a site or in an RSS information channel by the owner of the INFOADD address |
Beta Was this translation helpful? Give feedback.
-
Always thinking about upcoming legislation, this new network feature could support another important upcoming regulation: the digital sales receipt. The sales receipt, issued by companies selling services or products to individuals, is not mandatory in all countries of the European Union, but where it is required, ways to make it digital (while also saving a lot of paper) are being discussed. The issue is debated because it impacts privacy: with a traditional approach (already in use for digital invoicing) all receipts would be sent to a central system that would then learn about every expenditure made by the private citizen. One possible solution is to create an NFT containing the digital version of the receipt, encrypted with the customer's public key. This NFT would be exchanged atomically upon receipt of payment (in tokens) and in compliance with the GDPR cannot contain personal data of the customer. The complete procedure might look like this:
Authorities will always be able to verify that a certain supplier's cash input coincides with the issuance of a receipt to an address, which, however, is not representative of a specific individual. The supplier keeps the unencrypted copy so that it can prove that the encrypted version actually contains the given data (hash comparison). This system ensures the privacy of citizens, and no one can use the data from the digital receipt system for massive analysis of all citizen purchases. Finally, the citizen can always destroy his NFT receipt, as he does with the paper one today. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'm very much in favor of 6.2 and i don't think it needs a swap feature block as everything necessary is already implemented in stardust.
We can then offer a grant for someone to develop an open source UI (preferably as a webpage or firefly module) to interact with this "order book" - or let developers implement it with their own additional fee. As DEXes are the number 1 usecase of crypto currently, this would be a great selling point ("feeless DeFi"), is a great match for our stardust ledger in general with our native assets (can also create NFT "orders"), can be implemented really easily and bring highly welcome demand to throughput / mana. |
Beta Was this translation helpful? Give feedback.
-
Good morning everyone. This feature is certainly very important for many business use cases that I am encountering. Some I have described before, but I have new requests. The concern of many stakeholders is that the atomic swap can be used as to create spam. I think that spam should and is handled regardless of the type of tx. However, if we want to avoid with absolute certainty this risk, it is sufficient to define that an atomic swap tx must have a time validity that can be set and in any case not exceed a maximum (e.g.24). Exceeding this time it becomes invalid. |
Beta Was this translation helpful? Give feedback.
-
What about if we use the Alice sees(2nd layer application...) that 10 Bobcoins cost 300 IOTA. If Bob wants to 'swap' his 10 coins with 15 Alicecoins. He has to sell his 10 coins to somebody and buy 15 AliceCoins from somebody. They can see(2nd layer application...) at any time who is interested in buying their tokens. With this, we allow the sale of Outputs(I do not think it is possible right now)(Only works for NFT and Basic Output). With this, the swap is not atomic between different native tokens but is atomic between outputs and base tokens.
Pros
Cons:
Does this make sense? Methods 1 and 4 are the same and just need MultiAddresses. |
Beta Was this translation helpful? Give feedback.
-
Trustless Exchange of Native Assets
With the Tokenization & Smart Contract update of the chrysalis protocol IOTA becomes a multi-asset ledger with configurable outputs.
There are two kinds of native assets that may live in the ledger:
Both assets might be owned by user wallets on L1, or they can be deposited into smart contract chains (L2) for example to be traded on decentralized exchanges or marketplaces.
How can one exchange such assets with other parties? What mechanisms are needed on protocol level or what higher layer tools are required for trustless asset exchange?
Swaps
Swaps are trustless exchanges of digital assets and cryptocurrencies that are agreed upon by both parties.
The atomicity of the swap mechanism ensures that either both parties receive their intended assets or none of them, hence the trustless nature.
Depending on the swap mechanism, parties might need to establish off-chain communication and engage in a cooperative process to carry out the swap. In such cases an additional trusted communication medium has to be in place.
A distinction has to be made based on the assets to be exchanged:
Atomic Cross-Chain Swaps
To carry out cross-chain swaps one has to have access to both ledgers, and those ledgers must support a set of technical features to make swaps possible.
Hash Time Locked Contracts
One way to do it is to support the same hash function in both protocols that provide hashlocks, furthermore timelocks need to be available as well. In other words, both protocols must support Hash Time Locked Contracts (HTLCs).
The process of Alice and Bob performing a cross-chain atomic swap is illustrated below:
src: https://hackernoon.com/making-mast-meaningful-bitcoin-atomic-swaps-become-private-ff003f7c2b7a
Schnorr Adaptor Signatures
An alternative to hashlocks is Schnorr signatures which reduce the transaction footprint and increase privacy. The method makes use of the additive nature of Schnorr signatures.
The technical details are rather complicated, on a high level, the secret X is part of the multisignature address generation process. The protocol doesn't need to care about it, an atomic swap transaction looks like a normal transaction and is pretty lightweight on the protocol.
Conclusion
Regardless of the method chosen, parties do have to communicate off-chain, exchange addresses and secrets, while they also have to monitor both blockchains for transactions.
As a consequence, centralized bridge solutions emerged that are not trustless but offload these duties from users, trading security for convenience. Must crypto users do not seem to care.
The current IOTA protocol supports the Ed25519 signature scheme, which uses a variant of Schnorr signatures based on Curve25519. As such, cross-chain atomic swaps using adaptor signatures could already be performed directly from L1 as long as the counterparty supports the same signature scheme. Additionally, HTLCs are planned to be supported in the future.
On-Chain Swaps
On-chain swaps happen on the same ledger, which simplifies the procedure as multi-ledger access is not required. Only assets that are residing on the same network can be the subject to on-chain swapping.
Requirements of on-chain swaps:
Let's explore the different approaches that might be possible for on-chain swaps on IOTA.
Scenario: Alice has 10
AliceToken
that she wants to swap for Bob's 15BobToken
.1. P2P Off-Ledger Transaction Creation
Even if Alice and Bob do not trust each other, they can participate in the interactive off-chain process of constructing a transaction together, also called CoinJoin. They need to have a communication channel between them to facilitate the process:
AliceToken
to Bob's 15BobToken
.BobToken
and also his address.AliceToken
locked to Alice's addressBobToken
output locked to Bob's addressand the following outputs:
AliceToken
output locked to Bob's addressBobToken
output locked to Alice's addressPros
Cons
2. Hash Time Locked Contracts
The same process that was described above for cross-chain atomic swaps can be applied to on-chain atomic swaps. Alice and Bob need to have a communication medium to share addresses and hashed secrets, furthermore the protocol needs to support HTLCs.
Pros
Cons
3. Schnorr Adaptor Signatures
Instead of relying on HTLCs, Schnorr signatures provide another way to do on-chain atomic swaps. Still, there has to be an off-chain communication channel between the parties, but it is more lightweight on the protocol and preserves the privacy of the swapping parties.
Pros
Cons
4. Payment Channels
IOTA's version of bitcoin's Lightning Network was Flash Channels. These are off-chain payment channels that make it possible for parties to transact off-chain with high frequency. Such a payment channel can be opened by depositing funds to a multisignature address, generated by the participating parties. A second layer cryptography protocol is employed to carry out off-chain transactions, and when closing the channel, submitting the settlement transaction to the network.
Flash Channels are not supported any more since the Chrysalis Pt2 update, but it should be possible to revive them.
Pros
Cons
5. L2 Smart Contracts
Alice and Bob can ease the process and get rid of the necessary communication layer by relying on a L2 smart contract.
They both deposit their to-be-swapped assets into a smart contract chain, and call a smart contract to offer a swap. Upon this call, they can specify the conditions of the swap (price, expiry, etc.). The other party will query the smart contract for available swap offers and if there is one that they wish to enter, they just call the
accept offer
endpoint of the contract with needed funds and parameters to carry on with the execution of the swap.Once the smart contract reallocates the ownership of assets, both Alice and Bob can withdraw them to their L1 wallets.
Pros
Cons
Smart contracts also enable more advanced use cases of the same logic, for example DEXs and AMMs that pool offers and hence provide liquidity and market making.
6. L1 Output Feature Block
With the introduction of new output types and feature blocks, behavior of certain outputs can be programmed. Spending constraints can be embedded in outputs, for example timelock, expiry or dust return conditions.
What they all essentially do is to tie the spending of the output to some conditions defined on the spending transaction that defines their context. This context can record for example the original sender of the output too, making it possible to define spending conditions in relation to the sender's address.
The dust return feature is one example: When Alice wants to send native tokens to Bob, she can only create an output to Bob's address that also contains some dust deposit. Therefore, simply sending the native tokens with an output means that Alice loses ownership of the dust deposit, since the created output now belongs to Bob. In order not to loose those coins, Alice can define a dust return condition on the output: whenever Bob consumes this output, he will have to create an output that sends back the dust deposit to Alice. If Alice wants to get back the dust deposit in reasonable time, she also puts an expiry block on the output and states: if Bob doesn't consume this output in 1 hour, ownership of the output is transferred back to her.
The basic idea of swapping directly on L1 with output feature blocks follows the same logic, but the details should be carefully designed.
Swapping without smart contracts on L1 means that the actual swap is always required to have at least 2 parties both agreeing to the swap. There is no market maker entity who coordinates the activity of the involved parties, swapping on L1 requires user interaction.
6.1 Targeted Swap with L1 Outputs
Alice has 10
AliceCoins
which she wants to swap for 15BobCoins
. She knows Bob hasBobCoins
.Dust Deposit
+ 10AliceCoins
underAliceAddress
.BobAddress
in a transaction that depositsDust Deposit
+ 15BobCoins
toAliceAddress
BobAddress
by nodes.Dust Deposit
+ 15BobCoins
toAliceAddress
. He can take the 10AliceCoins
present in the consumed output and transfer it to an address of his choice.Pros
Cons
AliceCoins
. Bob then has no way to complete the swap, but the output is still mapped to his address, therefore it will be fetched by Bob's wallet when querying for outputs. Since node APIs have a hard limit on the number of returned outputs (1000 atm), Alice can DoS Bob's address with unspendable outputs so that he can not fetch other outputs truly belonging to him.6.2 Open Swap with L1 Outputs
Alice has 10
AliceCoins
which she wants to swap for 10BobCoins
. She doesn't know who hasBobCoins
.Dust Deposit
+ 10AliceCoins
underAliceAddress
.Dust Deposit
+ 10BobCoins
toAliceAddress
.BobCoins
and is willing to swap them for 10AliceCoins
can include and unlock this output in a transaction that deposits the needed assets toAliceAddress
.Pros
Cons
6.3 General Observations
The Option to Cancel
The option to cancel a swap seems to be a convenience feature for user experience. However, it immediately introduces non-deterministic output ownership which might lead to race conditions during confirmation and attacks against smart contract chains.
Note, that in IOTA we can not cancel a pending transaction by "reverting it". In Ethereum for example, it is possible to cancel a pending transaction if it is only in the mempool and hasn't been added to a block yet: you just send a transaction with the same nonce but higher fees. In IOTA, as soon as the transaction is sent to the Tangle, the only way to "revert it" is to introduce a double spend before confirmation happens. Since confirmation times are orders of magnitude faster than in Ethereum, it gives just a very small time window (~10s) and the double spend also needs to come first in the White Flag ordering.
Layer 2 approaches (1-5) which are built on top of L1 however may implement the option to cancel without introducing race conditions on L1.
Open Ended Swaps
When the other party of the swap is not known or irrelevant, the protocol must allow non-deterministic output ownership which leads to aforementioned problems.
From a practical point of view, the one creating an open ended swap also has to make sure to disseminate the availability of it to interested parties unless relying on a trusted third party to monitor the Tangle for such swaps.
6.4 Swap Feature Block Solution
In order not to cause problems, the swap output feature block must avoid:
Therefore, a swap feature block on L1:
The simple design is as follows:
Targeted Swap Block
optAnyOf
Native Token
optAnyOf
NFT Address
Additional Syntactic Transaction Validation Rules
Swap Amount
+Swap Native Tokens Count
+Swap Native NFTs Count
must be > 0.Swap Native Tokens Count
must not be greater thanMax Native Token Count
.Swap Native NFTs Count
must not be greater thanMax Outputs Count
.Additional Semantic Transaction Validation Rules
Sender
, the Targeted Swap Block is always valid. (Such an unlock can only be valid when an Expiration Block is present.)Address
, the Targeted Swap Block is valid if and only if the transaction depositsSwap Amount
of IOTA coins, allSwap Native Tokens
of their corresponding amounts, and allSwap NFTs
to the output'sSender
address. The deposit outputs must not contain any feature blocks that implement spending restrictions (dust return, timelocks, expiry, swap blocks, etc.).Sender
field, all theirSwamp Amount
,Swap Native Tokens
andSwap NFTs
values are summed up and the transaction must deposit at least those sums to theSender
address.Additional Ideas
Address
(recipient) field of the output shall not be added to the general Address -> Output LUT in nodes if the output contains a swap block.Address
(recipient) field of the output could be mapped in a separate LUT, which is exposed only under a different API endpoint. Of course this endpoint has the same DoS problems, but at least it is isolated to swap offers and doesn't affect regular outputs.Address
(recipient) field of the output could be unmapped, leaving it up to off-chain communication or third party service to index it for the recipient.Conclusion
Several ways have been shown how to facilitate trustless exchange of digital assets, on-chain and cross-chain.
Both have their pros and cons for the protocol and user experience. While the latter can be greatly enhanced by layer 2 applications built on top of the protocol, the former needs to be handled with utmost importance.
L1 is great for executing payments, but less suited as a communication channel or data indexing layer for clients. It is not the job of the core protocol to implement unattackable indexing for client side applications. A prime example of this is Cardano L1 smart contracts, where outputs are only indexed by script hashes. Unless a client knows the pre-image of the hash, it is impossible to find out who owns such an output and what one can do with it.
IOTA Smart Contracts on the other hand is a layer 2 solution where any application logic can be coded and also be exposed from smart contracts to clients. It is a good alternative to implement swaps, as any swapping logic can be programmed on it. DEXes, as a generalization of the swapping feature, can also run on ISC. Then users don't even need to bother to find another party, the automated market making mechanisms will execute the swap.
Of course the downside is that smart contracts might incur transaction fees on L2.
Feeless layer 1 swaps are only possible if the parties do have some off-chain communication method or use a trusted third party service for this purpose.
Questions
Beta Was this translation helpful? Give feedback.
All reactions