Image for post
Image for post

Inside PoolTogether v2.0

Brendan Asselstine
Aug 30, 2019 · 5 min read

The first version of PoolTogether was a roaring success: the community pooled over 150,000 DAI to generate nearly 800 DAI in prizes in only six weeks. The idea of interest as an instrument has now reached a fever pitch with a proliferation of clever projects such as rDAI and Pooled cDAI. We’re thrilled that this concept has gained traction and are excited to move forward alongside these dapps.

The PoolTogether community has given us great feedback in our Telegram channel, and we’ve been listening intently. From the praise, questions, and occasional scorn we determined that:

  1. Users must be automatically entered into the next Pool
  2. Users must be able to purchase tickets at any time
  3. Users must be able to withdraw at any time
  4. Funds must always accrue interest to maximize the prize

We’re thrilled to present how we accomplished these goals in PoolTogether v2.0!

PoolTogether v2.0

Automatic Re-entry Through Draws

There is only ever one open draw. All deposits to the Pool are recorded in the open Draw.

After a week has passed the open Draw is committed. These committed funds are added to the funds already in the pool. A user’s chance of winning is proportional to the ratio of their committed funds to all committed funds. For example:

If a user has 100 committed DAI in tickets, 40 open DAI in pre-purchased tickets, and there is a total of 1000 committed DAI in tickets then they stand a 10% chance of winning. Notice that the open DAI was not included!

After another week has passed the committed Draw is rewarded by computing the winner and updating their balance with the winnings.

It is important to note that there is always one open draw and one committed draw, so in fact Draws are overlapping.

It’s best illustrated with this table:

Draws progress in a rolling fashion

Pre-purchase Tickets at Any Time

Withdraw at Any Time

Funds Always Accrue Interest

Winner Selection

While not perfect, we believe that using the gross winnings is an improvement over using the blockhash as Compound is more difficult to manipulate directly. It’s possible to change Compound’s current rate (and therefore gross winnings) using vast supplies of DAI, but ensuring a particular wei value for the gross winnings would be extremely difficult as the numbers are a moving target.

Beneficiaries

The Pool contract stores two variables called the next fee beneficiary and the next fee fraction. When a new Draw is opened the fee beneficiary and fee fraction fields are initialized with the previously mentioned values, respectively. In this way each Draw “locks-in” the beneficiary and their fee.

We plan to use the beneficiary feature for two types of pools: the prize Pool and philanthropic Pools.

The prize Pool will have the beneficiary set to the Pool itself so that the winnings are compounded. The idea is to increase the capital of PoolTogether without decreasing each user’s odds so that it is more worthwhile to deposit into PoolTogether rather than Compound directly. Credit goes to Luke Duncan for the idea!

Philanthropic Pools will have a fee fraction of 100% and the beneficiaries could be any group from UNICEF to MetaCartel DAO.

The Algorithm in Plain English

  1. The Pool contract is deployed by a developer. They initialize the contract with an administrator, next fee beneficiary, and next fee fraction.
  2. The administrator opens Draw 1 using a hash of a secret.
  3. A user deposits into the Pool and the deposit is recorded in Draw 1.
  4. In one transaction the administrator commits Draw 1 and opens Draw 2 using another hash of a secret.
  5. Another user deposits into the Pool and the deposit is recorded in Draw 2.
  6. In one transaction the administrator rewards Draw 1 by revealing the Draw 1 secret, commits Draw 2, and opens Draw 3 using another hash of a secret.
    The beneficiary of Draw 1 receives a fee calculated by the fee fraction * gross winnings. The gross winnings is the accrued interest since the last reward. The winner receives the gross winnings less the fee.
  7. Go back to step 5 and increment all of the draw numbers by 1.

Upgradeability

Security Bug Bounties

For this version we’ve elected to publish the code before going to mainnet to allow for the full scrutiny of the community. We have established an official security bug bounty program, so if find any issues with the contracts we’ll be happy to reward you.

Launch Schedule

September 4th, 2019
Smart contracts go live on mainnet and the first Pool is opened!

Summary

If you have any questions, comments, concerns or praise please feel free to reach out! We love hearing from the community.

Find PoolTogether on Twitter or Telegram. See the code on Github.

PoolTogether

Updates & News From PoolTogether

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store