Intelligent atomic swaps and decentralized matching in the XCARD wallet
The new era of finance — a Decentralized Finance was born when the bitcoin network mined its first block in 2009. It introduced several nonexisting features before — full transparency, decentralization, none single point of failure, trustless consensus mechanism, and transaction immutability.
A kind of crypto fashion that followed has caused a surge of users, creating demand for exchanges. Bitcoin and other cryptocurrencies became popular speculative instruments.
Demands for exchanging the value was more electric than technology development, making current crypto space far from its roots — trading was dominated by centralized exchanges due to the adoption of widely known mechanisms from traditional trading platforms.
Business immaturity combined with centralized custodial hot wallets caused a lot of market anomalies — fake volume creation, price manipulation, hacks and financial losses for all market participants, bringing a lack of trust for newborn phenomena.
The above-mentioned faults caused a desire to return to the roots of blockchain introduced by Satoshi in his white paper. Work has begun on decentralized exchange techniques, the most popular of which are atomic swaps. Introduced in 2013 by Tier Nolan, it started to be popular when Litecoin founder Charlie Lee announced the successful execution of an atomic swap between Litecoin and Bitcoin.
What are Atomic Swaps?
According to the bitcoin wiki, „Atomic Swaps are decentralized and trustless trades between two users of different cryptocurrencies.” If you are interested in technical details, there is plenty of documents explaining the nature of atomic swaps and possible technical implementations (like most popular — Hash-Time-Locks).
Mobilum foundation and its XCARD wallet are built on the idea of entirely decentralized finance. We want to bring a solution that does not compromise customers’ funds’ security and follows our (almost) zero fees criterion. We decided to implement Mobilum as a decentralized multichain solution working in internalizing (also) mode. We use the technology of atomic swaps, which we call „intelligent atomic swaps” because of two reasons:
First, we try to maximize the liquidity of the market by playing an active role in market making currencies on our platform. It is done by our arbitration mechanism (supported by the pricing engine) which gathers in (almost) realtime data from different liquidity providers and compares with the decentralized order book on our exchange. The arbitration mechanism tries to maximize the order matching by providing a counterparty for orders which can not be matched between XCARD users, leveraging external liquidity and XCARD liquidity pools.
Second, we want to earn profits playing actively on external liquidity brokering, minimizing costs for our users to network costs only, not affecting our profitability.
How does the Atomic Swap work in general?
Let’s say you want to exchange your Bitcoins for Litecoins with a stranger. You agree with the exchange rate, but there is a problem who sends the funds first and if you receive funds in exchange.
So you both agree to participate in Atomic Swap of Bitcoins to Litecoins. You create a special wallet (a Hash Time Lock smart contract) and move your Bitcoins for swap there, so they can be publicly inspected by the second party. Then you send a special hash (lock) to the second party, who also creates a smart contract (HTLC) using the same hash and moves his Litecoins there for your inspection. Both funds can be released using the same key you hold, but by releasing Litecoins you disclose the key so your counterparty may use it to release Bitcoins. If something is not correct (number of Bitcoins or Litecoins in those contracts) you do not disclose the key and both expire — there is no transaction. That is the big picture.
How does the Intelligent Atomic Swap work in XCARD on the Mobilum Platform?
In general atomic swaps have some limitations. Both contracts need to use the same hash algorithm, both need to implement specific smart contracts. That limits its usage to supported coins only. Another limitation is a price negotiation between parties.
In XCARD we try to avoid those limitations by implementing an XCARD originator which is a kind of smart contract notary, that holds an order book of parties willing to exchange their coins and accepted price range. The notary contract works similarly to a matching engine, when buy order matches a sell order it creates two contracts for atomic swaps for each party of the transaction. There is a defined period for each party to move a specified amount of coins for a swap to that address. When both parties move coins a swap is being made by the smart contract. If not, the atomic swap expires. The smart contract notary checks also a membership requirement of each party (just to remind, each party is required to hold 0,5% of the transaction value in MBM Token). If any of the parties do not meet the membership requirement, a smart contract notary may refill it if agreed by the party.
Why we call our atomic swaps “intelligent”?
Our smart contract notary has an algorithm that tries to match maximum orders volume having in mind parties constraints in terms of agreed swap price. To do so, it connects with our pricing engine and virtual order book to examine the best price on the market.
XCARD animates supported currencies using XCARD liquidity pools by providing a second party to the transaction that can not be matched by the platform users when it fits its pricing algorithm. Smart contract notary algorithm polls the XCARD animator service each time it uses a price engine to check whether a particular swap should be done internally (between XCARD users) or involve the XCARD liquidity pool.
Both parties may request XCARD liquidity involvement in case of a private transaction requirement. In such a case, XCARD uses its mixer functionality, which hides exact volumes and destinations of transfers (more information will be provided in another article).
Atomic swaps have a significant impact on cryptocurrencies and their holders. It gives light on bringing its “currency” nature as it allows trustless exchange and acceptance. We, XCARD are committed to providing the best available secure and decentralized environment for our customers.
We are currently working on a technical paper which describes given functionality in detail. The article will be published within a month.
XCARD is an all-in-one digital wallet and the most convenient crypto credit card. Our mission is to connect fiat currencies and crypto assets in real-time. You can store, trade and exchange them instantly, and spend anywhere you want, with no limitations.
Join our Telegram and chat with us! -> https://t.me/mobilumcom
Visit our website -> https://xcard.io/
Read our whitepaper -> https://xcard.io/static/XCard-Whitepaper-21082019.pdf
Thank you for reading!