The path to launching STX.SWISS
One of blockimmo’s core value propositions is bringing liquidity to the real estate market. To accomplish this, we realized there needs to be a liquid, (regulatory compliant) secondary market for security tokens (tokenized real estate is a security). We started looking around and quickly realized nothing was close. So we decided to do it ourselves. A year later we are excited to announce that STX has launched! This post tells the story of how we got here.
Introducing STX.SWISS — Decentralized Security Token Exchange
The future of trading digital assets completely decentralized
A year ago if you wanted to enable a secondary market on your platform 0x seemed to be the obvious choice. So we did a quick prototype enabling the peer-to-peer exchange of blockimmo-issued real estate tokens at https://blockimmo.ch/trade. We even started talking to regulators about our approach.
As we dug into 0x more and started seriously architecting STX we found ourselves struggling with a bloated, overly-complex protocol that had a utility token shoved into it like a screw hammered into a stone. All this for simple token swaps 🤯? The straw that broke the camel’s back was discovering a centrally controlled proxy that could “result in the [proxy] owner verifying a malicious address that then proceeds to transfer all the allowed funds to their own wallet.” Consider the common (anti) pattern we see today where DApps and DEXs have users grant smart contracts permission to transfer an infinite amount of tokens from their wallet, on their behalf, and you’ll see why this backdoor is unacceptable for a protocol claiming to be decentralized. Note: STX does not follow this anti-pattern — users grant an allowance for the exact amount of tokens per trade, nothing more.
Why 0x is not as trustless as it may seem
One of the main benefits of DEXs is that they are trustless and non-custodial, they allow users to trade their funds…
Implementing our own DEX with an on-chain orderbook
Swapping tokens on Etheruem isn’t complicated. The ERC20 standard is well designed for it with
transferFrom. So we built a simple
Exchange smart contract with an on-chain order-book that enabled a decentralized, non-custodial DEX. No wrapping Ether, no fees (value held in escrow by the
Exchange automatically loaned via Compound.finance), and around 100 lines of code. This exchange was part of our open HackerOne bug bounty and was audited by Chain Security.
Our matching engine was off-chain (and optional, users could directly fill, partially fill, and fill multiple buy/sell orders at once by interacting directly with the
Exchange smart contract). Keeping the order-book clean (pruning) was incentivized as buyers and sellers filled/placed orders (gas cost reduced as orders were automatically removed and storage freed). No centralized party had access to user funds meaning minimal risk and we didn’t need to insure hot-wallet funds (an extremely expensive cost centralized exchanges bear).
The main challenge we faced was market making as it required partner(s), liquidity, and a strict regulatory framework to comply with. We also faced many edge cases that come with an order book, and started to realize how much has to happen behind the scenes to build a solid, regulatory compliant exchange with a good user experience and low fees.
No free lunch
We faced some challenges with both 0x and our custom
Exchange. 0x’s off-chain order-book meant an additional (slightly complex) centralized component we needed to implement in our system — the Relayer. Our custom
Exchange's on-chain order-book meant higher transaction fees, but a more transparent, trust-less, and much simpler overall system.
In both cases we needed to implement a matching engine and market-make (requires liquidity) to provide a good UI/UX. Which turns out to be the difficult part of building a solid exchange. At this point, neither approach seemed to accomplish our goal of building a decentralized exchange.
Enter Uniswap 🦄
Uniswap is a protocol for automated token exchange on Ethereum. It is designed around ease-of-use, gas efficiency, censorship resistance, and zero rent extraction. It is useful for traders and functions particularily well as a component of other smart contracts which require guaranteed on-chain liquidity.
Uniswap does something amazing — it removes the order-book and matching engine from the overall system, and distributes market making over liquidity providers (incentivized by the 0.3% Uniswap transaction fee which can be thought of as the market makers’ spread). Uniswap is a truly decentralized exchange, native to Ethereum, while 0x and our
Exchange were “ported from the old-world to Ethereum.”
Uniswap radically simplifies and decentralizes the overall system powering an exchange. The complexity of this system is not implemented on-chain or directly in the rules of the Uniswap protocol. Instead, almost all complexity is off-loaded onto the market/participants interacting with the protocol. Just like a public blockchain, Uniswap is built to thrive in the wild by aligning itself with the incentives of the market, and flowing with market forces like a Brazilian jiu-jitsu master. The result is a dirt simple protocol composed of purely “hard-code” which provides determinism and a much easier way to interact and analyze the protocol (ie liquidity, price discovery, (real) volume). Where previous approaches like 0x and our
Exchange had a lot of “wet-code” required to get the system to behave correctly (ie the Relayers in 0x’s case, and market maker(s) in both cases, even the matching engine starts to look “wet” when you have to license propreitary order-book / trade-analysis software).
I highly recommend reading the whitepaper if you haven’t https://hackmd.io/C-DvwDSfSxuh-Gd4WKE_ig.
After Uniswap launched we kept a close eye on it, watching how it performed in the wild, and quickly realized it was the right protocol to build STX on. It performed well with little liquidity (usually under 1% of a token’s market cap) and low volume, which is important because we expect this at first with the securities we list on STX.
The goal of STX is to be a regulatory compliant decentralized exchange for securities. At the moment there aren’t really any (regulatory compliant) securities to trade though. So in the meantime we launched STX with some popular tokens listed (DAI, MKR, XCHF), and (BAT, KNC, etc…) are coming soon. This way people can already start using STX and we can test and refine our technology with real use.
Because these tokens are not securities we do not require KYC/AML to trade them. So anyone with an Ethereum wallet can start trading right away! To trade securities (once listed on STX) everything is the same, but users will need to on-board first.
For now STX can be thought of as a frontend for Uniswap. There are no additional fees. We are implementing some additional features like limit buy and sell orders and stop losses which should make STX an attractive way to interact with Uniswap.
Give it a try! https://stx.swiss