PoolTogether 3.0
HomeAppBuilder
v3.0.1
v3.0.1
  • ✨Introduction
  • 📡Networks
  • 💱Migrating from V2 to V3
  • 🚰Resources
  • Protocol
    • 🌐Overview
    • 🏆Prize Pools
      • ⚖️ Fairness
      • Compound Prize Pool
      • yVault Prize Pool
      • Token Listener
    • 💸Prize Strategies
      • 🤑Single Random Winner
        • 🎟️ Ticket
        • 🎁Sponsorship
    • 🧞Random Number Generator
      • Blockhash
      • Chainlink VRF
  • Tutorials
    • Getting Started
    • Deposit into a Prize Pool
    • Withdraw from a Prize Pool
    • Create a Prize Pool
    • Create a Prize Strategy
  • Governance
    • 🏛️ Overview
    • 💰Comptroller
  • Security
    • Risks
    • Audits & Testing
    • Bounties
Powered by GitBook
On this page
  • Approve
  • Deposit
  • Depositing Sponsorship
  • Depositing for Someone Else
  • Capturing Referral Rewards

Was this helpful?

  1. Tutorials

Deposit into a Prize Pool

How to Buy Tickets in a PoolTogether Prize Pool

PreviousGetting StartedNextWithdraw from a Prize Pool

Last updated 4 years ago

Was this helpful?

Let's deposit into a Prize Pool. Each step of the way we'll show you how to do it in both Solidity and Javascript (using ).

First, we'll need to identify what the underlying asset to be deposited is. If it's a Compound Prize Pool, we'll want to check which cToken it is.

Let's assume we have a Compound Prize Pool that is built against cDai.

Approve

Let's approve the Prize Pool to spend 1 of our Dai:

Solidity

DAI_ERC20.approve(CDAI_PRIZE_POOL, 1 ether);

JavaScript

const ethers = require('ethers')
const signer = ethers.Wallet.createRandom()

const dai = new ethers.Contract(
    DAI_ADDRESS,
    ERC20_ABI,
    signer
)

const daiPrizePool = new ethers.Contract(
    DAI_PRIZE_POOL_ADDRESS,
    PRIZE_POOL_ABI,
    signer
)

await dai.approve(daiPrizePool.address, ethers.utils.parseEther('1'))

Deposit

Solidity

address ticketAddress = SINGLE_RANDOM_WINNER.ticket();

JavaScript

const strategyAddress = await daiPrizePool.prizeStrategy()

const singleRandomWinner = new ethers.Contract(
    strategyAddress,
    SINGLE_RANDOM_WINNER_ABI,
    signer
)

const ticketAddress = await singleRandomWinner.ticket()

Now let's deposit to mint tickets for ourselves:

Solidity

CDAI_PRIZE_POOL.depositTo(
    MY_ADDRESS,
    1 ether,
    ticketAddress,
    address(0)
);    

JavaScript

await daiPrizePool.depositTo(
    signer._address,
    ethers.utils.parseEther(1),
    ticketAddress,
    ethers.constants.AddressZero
)

Depositing Sponsorship

If you wish to deposit and receive sponsorship, or any other controlled token, you simply need to pass it in as the controlledToken argument.

Depositing for Someone Else

If you'd like to deposit on someone else's behalf, you can simply change the to address in the call to whomever you want to receive the tickets. Note that the caller will not be able to withdraw the funds; those funds can only be withdrawn by the recipient unless they increase your allowance.

Capturing Referral Rewards

The last parameter to the depositTo function is the referral address. The protocol may drip referral awards globally to Prize Pools. Referrals can earn tokens based on the fraction of referral volume they supply.

Any interface for a PrizePool will want to pass it's own address as the referrer so that it can capture sweet, sweet rewards.

Now let's deposit into the Prize Pool. Since we're depositing into a that uses a strategy, we'll want to mint Tickets so that we're eligible for prizes.

We can retrieve the Ticket address from the Single Random Winner prize strategy:

For more information see

Ethers.js
Compound Prize Pool
Single Random Winner
Rewards
controlled token