Securing Gnosis’ Dutch exchange smart contracts — a case study.

Blockchain is growing up. Gone are the early days of loosely connected individuals and the absence of established actors, companies and brands. Today, we are on the path to a wholesome ecosystem of services, providers, and solutions that are native to the scene.

One of these players is Gnosis. We met the prediction market provider at EthCC in Paris last year and were thrilled to learn about their plans to grow the Blockchain ecosystem beyond their specific field of business. Recently, we helped them secure their Solidity code for an ambitious project, for which flawless smart contracts are definitely crucial. Together we documented the successful and pleasant collaboration.

Hi Nadja, hi Chris. Thanks for doing this case study with us. Tell us something about Gnosis.

Nadja: Gnosis builds new market mechanisms to enable more informed decision-making and distribution of resources at individual, societal, and global scales. Gnosis was founded as part of ConsenSys, the globally leading Ethereum venture production studio, in 2015 by Martin Köppelmann and Stefan George.

Nadja (l) is responsible for Gnosis’ brand & content strategy, Chris is the DutchX product manager.

We became a fully-fledged company early 2017, and were able to raise sufficient funding for the next years to come. Our Berlin team members recently moved into our brand new co-working space Full Node in the heart of Berlin Kreuzberg.

Gnosis’ new crypto centric co-working space in Berlin, Kreuzberg.

Chris: While our prediction market platform allows anyone to build customized forecasting applications, the DutchX contributes to a fair price finding of tokens.

The DutchX is a decentralized exchange for ERC20 tokens, based on the Dutch auction principle. The mechanism design of the DutchX implies that sellers submit their tokens ahead of an auction. Then, the auction starts with a high price which falls until the market for the specific token-pairing clears. Bidders submit their bids during the auction, but pay the same final price. Hence, the dominant strategy for bidders to reveal their true willingness to pay will result in fair market prices.

We are super excited to launch the exchange fairly soon! Our next blog post in the DutchX series will shed some more light on our vision and how we see the DutchX as an open platform for the fair price finding of tokens.

What’s the purpose of the smart contracts we secured together?

Alex is one of the authors responsible for the DutchX smart contracts.

Alex: While our smart contracts facilitate to trade tokens using a Dutch auction mechanism, they also have a lot of fancy features. The trading using Dutch auctions was actually pretty easy to implement, but we added a unique honey-pot scheme to the platform in form of Magnolia tokens. Magnolia tokens reward market makers and those with high trading volume by reducing their fees. This is not the only incentive mechanism, though: fees get redistributed within the DutchX ecosystem as well. Also, we ensured that other smart contracts can easily build on the DutchX for specific tasks. For example, a token lending or shorting mechanism would be a great application on top of the DutchX.

Did you use any tools/tactics/practices to secure the code before starting the audit?

Alex: We actually did quite a bit: Firstly, we spent a lot of time to get the game mechanics of the smart contract right. It sounds all easy, but we designed the exchange in several iterations to make sure it is secure. Secondly, we tried to apply strict security standards to prevent bugs. Also, we formally verified that no tokens could ever get stuck in the exchange. A particularly interesting part are all the proxy contract constructions. They were analyzed in byte code to ensure their safety and gas efficiency. Of course, we also took a look at the catalogue of known weaknesses and tried to spot them in our contracts. But most importantly, we wrote a ton of tests. From very general system tests, state flow tests to very specific unit tests. We also did a prior internal review of the code before handing it over to Solidified.

How did you find out about Solidified and what made you choose them?

Chris: We were actively searching for an auditor. Highly competent auditors are not that common in the blockchain space and often booked out in advance, or even too busy to respond.

Back in early March, we went to the Ethereum Community Conference in Paris and by sheer luck, Stefan, our CTO, stumbled across some auditors that are part of the Solidified community. They even listened to my DutchX presentation and asked some great, yet tough questions at the end. We only realized later that those came from Solidified auditors! It’s really fantastic that they are not only Solidity and smart contract experts, but also very knowledgeable in game theoretical design, which is a big part of the DutchX.