Atomic exchange of asset within same address (at fixed rate if possible)

+2 votes
Let's say we have a blockchain with 2 assets issued (USD and EUR).

Imagine Node X has 100EUR and wants to "exchange" them for 118USD (1.18 rate)..

Is it possible that a node executes an atomic exchange of different assets from and to itself?

As a bonus: is there a "safe" way to ensure that proper official exchange rate is applied at the moment of the transaction? (appart from changing Multichain source code to support that, I mean)

Thank you very much.
asked Nov 16, 2017 by Xavi

1 Answer

0 votes

Yes, a node can certain perform an atomic exchange between two of its own addresses. You just go through the standard process, specifying the address to use each time you run preparelockspentfrom.

There is currently no way to enforce a particular exchange rate at the blockchain validation level.

answered Nov 16, 2017 by MultiChain
Would it be safe and sound to add a exchange rate enforcement using streams?

Something like this (pseudo-stuff ahead):

create stream xchg false
publish xchg EURRate 1.18 (in hex format)
publish xchg USDRate 1.00 (in hex format)

...
issue 1... EUR 1000 0.01 ... xchg.EURRate (new parameter)
issue 1... USD 1000 0.01 ... xchg.USDRate (new parameter)
...
and then the blockchain would be able to enforce the exchange rate by taking the latest values for the stream keys associated to assets involved in transaction.

Enforced exchange rate in a EUR/USD tx would be then xchg.EURRate/xchg.USDRate = 1.18/1.00 = 1.18
No I'm afraid this kind of enforcement is not currently supported by MultiChain.
...