Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Decentralized exchange provides an ability to transfer assets between accounts in exchange for other assets. Let's use a simple case as an example:

Peer to Peer Scenario

PlantUML diagram

Expand
titlePlant UML


No Format
nopaneltrue
@startuml
Buyer -> Iroha: Place Exchange Order(20XOR, 100USD)
Seller -> Iroha: Place Exchange Order(100USD, 20XOR)
Iroha -> Iroha: Transfer 20XOR from Seller to Buyer
alt Success:
  Iroha -> Iroha: Transfer 100USD from Buyer to Seller
end
@enduml


...

But there are more corner cases when we deal with exchanges via bridge:

Peer to Peer across Bridge Scenario

  • Cross blockchain rates should be taken into consideration
  • Iroha should prevent double spent of assets 
  • Additionally to transferring assets, Iroha should mint and demint themde-mint them

Liquidity Pool Scenario

Liquidity Pools is another dimension in this set of scenarios for Decentralized Exchanges. Basically it can be used in pair with or without bridges, so let's take a more clean example without them.

Resulting Behavior

Let's write all three scenarios as one feature description according to BDD:

No Format
nopaneltrue
Feature: Decentralized Exchange
  Scenario: Buyer exchanges 20xor for 100usd
    Given:
    When:
    Then:
  Scenario: Buyer exchanges 20xor for 100usd
    Given:
    When:
    Then:
  Scenario: Buyer exchanges 20xor for 100usd
    Given:
    When:
    Then:


Solution

Introduce a new module "DEX" with a dependency on "Bridge" module with additional set of Iroha Special Instructions and Queries and new Abstractions like Order (Combination of a Trigger and Asset with a predefined Asset Definition). Implement Triggers.

...