EDIT: it seems that there's a better solution
It seems the better solution was already proposed here:https://bitcointalk.org/index.php?topic=22581.0
I've been asking myself lately whether if a chain for exchange blockchain crypto-currencies would need modifications on bitcoin or not.
To simplify, we just want to trade bitcoins and namecoins.
You have to read this:https://en.bitcoin.it/wiki/Alternative_Chains#Paying_for_resources_on_alternative_chains_with_Bitcoins
Of course you could modify bitcoin (and namecoin) to allow conditional transactions that are valid or not depending on what appears in this other network (and namecoin's chain), but that's not very scalable and modify bitcoin rules to build an exchange is ask for too much.
My solution requires another currency, middlecoin or exchangecoin.
You can have atomicity to exchange bitcoins or namecoins for middlecoins just as described in the link.
Well, an example.
I set a buy order of 1 btc for 10 middlecoins.
A seller accepts and creates a conditional transaction "send 10 middlecoins to the address in the buy order MDC address only if this BTC address receives 1 btc within the next X btc blocks".
The same would apply to trade nmc/mdc.
Now say you want to trade 1 btc for 10 mdc and those 10 mdc for 3 nmc, that is 1 btc for 3 nmc.
And another person wants to do the opposite thing. One can send his nmc but not receive the btc. In that case you still have the 10 mdc and the other part could be punished by losing an additional escrow (also in mdc). That last part would be equivalent to agree a higher price than the market's for both linked transactions.
What do you think?
What problems do you see with it?
EDIT: In this thread
I propose to separate middleCoin and exchangeChain.
If either bitcoin or namecoin adapts, there would be no need for middleCoin.