⚗️ How to realize same chain trades on Ethereum #665
Comments
DesignSince we are doing a same chain trade, we don't need HTLCs and we can do non-interactive multi-party asset exchange: This means that:
Ether to ERC20Alice wants to sell A Ether to anyone who will give her B of some ERC20. Alice deploys a contract from her address
The contract can be called in two ways: By any address other than Alice's (
|
Note: there is one error in your description but I assume you meant the following:
(same same but different for the otherway around :D ) Two thoughts on that:
Afaik, even if we have a stateful contract, we will need these 3 transactions, however, we can get rid of the costly HTLC deployment transaction. |
@bonomat The goal of the protocol is for it to be non-interactive. So Alice puts up the contract and lets anyone in the world take the trade without interacting with her (Bob is just the name of the guy who was fastest to take the offer). There is no need for HTLCs because we're not sharing state across blockchains. I'll add more details making this clearer and add the It does seem like we'll always need three transactions, which is lame because Bitcoin only takes one to do the same thing. |
Ether to ERC20Yes I was going to say, how come the contract can transfer Bob's ERC20? I guess Bob needs to give it the right to transfer them, right? ERC20 to ERC20Approval are missing, right? I guess Alice in this case can cancel the offer by just cancelling the approval. Is that possible using ERC20 API? |
True, an actual HTLC is not needed. Just replace @D4nte: |
@bonomat @D4nte I rewrote the original to include missing pieces and motivation.
To condition a same chain trade on a cross chain trade? Yes in this case you would need a HTLC. You could use a single HTLC that holds two assets to do this (I think). This would definitely be a different RFC/contract. |
I like the idea of non-interactive trades. Good stuff. We should investigate whether Gas considerationsIn order to make things really atomic, we will have to look into:
RFC considerationsI think there should be 1 RFC that specifies same chain trades on Ethereum between Ether and ERC20. BAM considerationsSince it is non-interactive, this will neither use the HTTP API considerationsVery likely a new sub-resource under |
Before we jump into non-interactive trades on Ethereum and write a RFC, please have a look at all the decentralized exchanges out there. To name a few: 0x, etherdelta , kyber network , idex, waves, ethfinex , radar... Most of them are completely open source and provide a proper protocol to use. We might need to clarify the goal of this ticket but if it's just Ethereum same chain trades, than we can really just use a solution which is out there already and skip the RFC. I think the fun part starts when the protocol enables multi-hop trades on the same chain or in combination with cross-chain, partially execution of trades. |
Yes. Same chain trades are far better because the blockchain itself is the decentralised exchange. The COMIT node can still play a role in verifying and interpreting the blockchain I think.
I looked into this and unfortunately it looks like Bob has to do an approve first.
There's a
If we run out of gas it should
Yes I guess you just have a system that whenever if finds a possible same chain trade on ethereum it posts it to the COMIT node which verifies it and produces the actions to "approve" and then poke the contract actions. |
Very interesting point. I didn't even think that far :) |
Are you saying we should copy the protocol or make the COMIT node compatible with any of those exchanges? |
Using one obviously :)
In this case we don't need the COMIT node at all:
Correct, we verified that in our last hackathon remember?
Yes, this is correct. Unless a contract checks for gas and does not call |
@LLFourn : one note on your cancel approach: The one with the better connection to the Ethereum network has an advantage (or the one being able using the least amount of gas):
-> I did this on etherdelta: I monitored the blockchain for fatfinger offers (too many zeroes, etc): immediately fired a transaction (1 block afterwards). If I saw another incoming transaction in the same block, I tried to front run it with a higher gas price. There was some good money to make from this :) I think we should design the contract in a way that Bob can safely redeem without being afraid of being front run by a cancelation. |
Talked with @bonomat and came to the following outcome for this ticket:
|
DoD:
|
Let's wait until everyone is in office. |
Meeting invite sent for Monday. |
Unblock, @LLFourn to write down decisions. |
We left the discussion with the following resolutions:
|
DoD
Child of #663
The text was updated successfully, but these errors were encountered: