Decentralized accounts (dAccs) allow users to control funds directly in a secure, multisig wallet while simultaneously taking advantage of the speed and liquidity of centralized exchanges. This is conducted solely through the channel-state exchange procedure within Xena Exchange. This approach helps reduce customer counterparty risk by up to 90%.


Excursus:
Xena Exchange is the only centralized crypto exchange that implements the principles of fund segregation. Counterparty (exchange) risk is one of the primary risks to consider when trading cryptocurrencies. In contrast to traditional financial markets, where different institutions, such as exchanges, brokers, clearing houses, and banks, provide infrastructure to minimize such risks, in the cryptocurrency market, an exchange is usually the combination of all these institutions into one entity. Trading cryptocurrency requires depositing funds to an account opened at an exchange, which, in most cases, is not regulated. Within the exchange, the funds are tracked off the blockchain, so in general, clients have little control over their funds. Decentralized exchanges (dEx) have the same (if not greater) counterparty risk, but they also introduce additional problems that make the whole concept nonviable.


Decentralized accounts reduce counterparty risk and allow clients to transfer funds from a secure wallet to their account in less than a second to mitigate increased market risks.


How do dAccs work?

The working principles of dAccs are similar to those of the Lightning network. They include off-chain state exchanges within a channel and take less than a second. 


Example:

  1. If Alice traded without dAccs and decided to open a position for 60 BTC, she would likely decide to use a leverage of x2 to x3 as the collateral (20 to 30 BTC). She would need to deposit all these funds to her account on the exchange, and the funds would be exposed to counterparty risk.

  2. Let’s consider the case of dAccs. Alice creates a channel and deposits 50 BTC. The channel-opening transaction is settled to the blockchain, creating a multi-sig wallet storing these funds.

    1. Xena Exchange can withdraw 0 BTC

    2. Alice can withdraw 50 BTC

  3. Before opening her position, Alice signs and sends a new state of the channel to Xena Exchange. This state is something like Xena Exchange – 3 BTC, Alice – 47 BTC.

  4. After receiving the new state, Xena Exchange updates the balance of Alice’s account, which is now 3 BTC. Alice can open the position for 60 BTC with a leverage ratio of 1:20. Alice’s risk on Xena Exchange is only 3 BTC, which is only a fraction of the total counterparty risk she could have had.

  5. If the margin level of Alice’s account approaches the stop-out level, Xena Exchange issues a margin call. Then, Alice can send a new state of the channel to allocate more funds from the multisig wallet to her account on Xena Exchange in less than a second.


To better understand how dAccs work, let’s take a closer look at the Lightning network.


Excursus: Lightning network. 

The Lightning network is a network built over the Bitcoin blockchain that operates with the notion of channels. When opening a channel, two parties commit a portion of their funds to a multisig wallet. To withdraw the committed funds from this wallet, either party needs signatures from both parties. When using a channel, the parties exchange new states of the channel that show the new distribution of funds. This happens off-chain, so the exchange can be as fast as required. When the channel has a new state, either party can close it, settling this state to the blockchain at any time. There are also special mechanisms in place that allow parties to retrieve the funds after a certain amount of time if the second party does not respond or close the channel in the normal way. They can also retrieve the entire amount allocated to the channel if the second party attempts to cheat. In a nutshell, it works like this:

  1. Alice and Bob create a channel. Alice commits 10 BTC, and Bob commits 5 BTC. After settling the special channel-opening transaction to the blockchain, 15 BTC is stored in a dedicated multisig wallet, and the parties have the following transactions in the channel (not settled to the blockchain):

    1. Alice submits a request to withdraw 10 BTC from the multisig wallet, signed by Bob

    2. Bob submits a request to withdraw 5 BTC from the multisig wallet, signed by Alice

    3. Either party can add their signature to the request they have submitted and settle it to the blockchain at any moment

  2. Alice buys something from Bob and wants to pay him 2 BTC. She exchanges the new state of the channel with Bob using an off-chain means of communication. Now:

    1. Alice has a request to withdraw 8 BTC from the wallet, signed by Bob

    2. Bob has a request to withdraw 7 BTC from the wallet, signed by Alice

  3. This process can be repeated until both parties decide to close the channel. To do so, both of them must settle, broadcast the last state of the channel to the blockchain, and redistribute the funds from the multisig wallet to their personal wallets.