Degens Smart Contract

Degens
3 min readSep 11, 2019

Today we’re releasing the smart contract for the Degens betting exchange platform:

We genuinely believe in openness and transparency, so will be open sourcing a lot more stuff in the near future, as well as launching the Degens dApp, naturally!

Audit

In addition to a pro-bono community audit of the original SportCrypt contract, we have now completed an audit by a respected security auditing firm, Quantstamp:

Quantstamp considers the quality of the code high

For full details, please read Quantstamp’s audit report of the Degens contract.

Our experience with Quanstamp was very good. They were professional and thorough, even on the short-timeframe deadlines we requested. As a consequence of the audit, we’ve developed a test using the Z3 constraint solver to verify some aspects of the contract execution.

New features

Although it’s based heavily on SportCrypt, there are a few new features in the Degens contract that we will use to improve the performance, user experience, and other aspects of the system:

  • ERC-20 token support: One of our most common feature requests has been to add support for betting in tokens other than ETH. In particular, DAI from MakerDAO has been a common request, since people are worried about the price volatility that comes along with ETH. The Degens contract does not hard-code token addresses anywhere, so we won’t require any contract upgrades when multi-collateral DAI is deployed, and also gives us the option to support related tokens such as cDAI, if there is sufficient user demand.
  • Decentralized contract: The SportCrypt contract has trusted “owner” and “admin” addresses. While these addresses could never do nefarious things like steal user balances, they still represented a point of centralization in the system. We’ve gotten rid of them in Degens. Now the contract gives no special privileges to us, or any other address. There is still an aspect of trust in selecting trusted graders that will decide the outcomes of matches, but the smart contract itself can be used on equal terms by anybody, even potentially competing exchange or sportsbook platforms. You can read more about how this works in our protocol documentation.
  • Batched trades: In SportCrypt, when you clicked “take” you could only attempt to trade against a single order per transaction. While it was technically possible for sophisticated users to use a proxy smart contract to batch trades, this is something that we want to allow everyone to do through the UI. Now, you can specify multiple orders to be traded on in the same transaction. By ordering them by price, you’ll ensure you get the best possible odds by filling the best orders first.
  • Order matching: Occasionally, the SportCrypt orderbook would have “crossed prices,” meaning that a bid is actually for a higher price than an ask. This could happen due to a market maker making a mistake (which we are working on preventing with a smarter UI), but most commonly it happens just as a natural course of events when two users price an event differently. In SportCrypt, an arbitrage bot could execute both trades (even atomically, using a proxy smart contract), but it would require sufficient collateral to execute one of the trades. The Degens contract provides a way to do this without needing any collateral. This should result in a more efficient market, as well as allowing us to implement some improved types of UI experiences such as “gas-less bets”.
  • Cancel All: In SportCrypt, it was impossible to cancel multiple orders in a single transaction, requiring users to execute multiple transactions to do so. Now this can be done in a single transaction, and the next version of our GUI has a button labelled “Cancel All”, but affectionately known as the “panic button”.

The Future

We’re really excited to show everyone the next iteration of SportCrypt, so please subscribe to our Medium/Twitter/Reddit, and keep checking degens.com!

--

--