Architectural changes to Acuity Atomic Swap DEX

Originally published 6th February 2022

The Acuity DEX has been making a huge amount of progress towards launching an MVP, as can be seen from recent videos.

A major goal in the design of the exchange has been to make it as autonomous as possible with all of the critical functionality written in smart contracts and Substrate pallets. This has had to be balanced against other concerns such as transaction fees. To this end it was decided to have an off-chain indexer component written in Rust. It listens to relevent events on participating blockchains, indexes the data in a centralized database, and responds to WebSocket queries from the exchange app running in the browser.

This works extremely well, although it did add a lot of complexity to the system. While the indexer is read-only and does not have any control over the exchange it is still a central point of failure.

During testing it became apparent that the system could be simplified even further, removing the off-chain indexer, and reducing gas costs at the same time. This will make the Acuity DEX fully autonomous.

Autonomous Cross-chain Trading Protocol

Here's how it works:

  • The seller must link their ACU account to the account on the blockchain they are selling from. They do this by publishing the opposite address on both blockchains.
  • The seller locks up funds in the Acuity smart contract on the blockchain they are selling from. In the transaction they indicate which asset they wish to buy. The smart contract maintains a singly-linked list for each pair with the largest deposits at the top. This is an anti-spam measure. The seller can add / remove funds at any time or change the asset to be bought.
  • The seller then publishes their sell orders on the Acuity blockchain. Sell orders can be modified very cheaply because they are maintained in a dedicated pallet on the Acuity blockchain.
  • For any given pair, the front-end (hosted on IPFS) can query the selling blockchain directly and get the list of deposits. It will then query the Acuity blockchain for each of these deposits to get their sell orders. These are then sorted and presented to the user in the UI.
  • The buyer locks up funds to purchase from a specific sell order. The atomic swap proceeds in the same manner as the current implementation.
  • Other than blockchain transaction fees, there is no fee to trade on Acuity DEX.

Advantages over previous implementation:

  • No central point of failure. The whole system is fully autonomous. No one can stop you from trading.
  • Lower transaction fees - with the current implementation you have to pay for transactions on the selling blockchain even to change the price you wish to sell at. Now the order book is maintained in a native pallet on the Acuity blockchain.
  • Publishing of sell orders on the Acuity blockchain will increase the monetary velocity of ACU.
  • We can launch sooner.

Just about any EVM-compatible blockchain will added to the exchange, including Ethereum, Optimism, Arbitrum, Ethereum Classic, Moonbeam, Avalanche and Solana. Initially only the base cryptocurrency of each blockchain will be supported. Later an improved version of the EVM smart contract will be deployed to all chains to enable cross-chain trading of all ERC20 tokens between all EVM blockchains.

Staking & Trading

Staking has been re-enabled on the Acuity blockchain. Become a nominator or validator to secure the network and increase your ACU holdings.

Until the DEX launches, ACU can be traded OTC on Discord.