{
  "address": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
  "abi": [
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_owner",
          "type": "address"
        },
        {
          "internalType": "contract IPrizeTierHistory",
          "name": "_prizeTierHistory",
          "type": "address"
        },
        {
          "internalType": "contract IDrawBuffer",
          "name": "_drawBuffer",
          "type": "address"
        },
        {
          "internalType": "contract IPrizeDistributionBuffer",
          "name": "_prizeDistributionBuffer",
          "type": "address"
        },
        {
          "internalType": "contract ITicket",
          "name": "_ticket",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_minPickCost",
          "type": "uint256"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "constructor"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "previousManager",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "newManager",
          "type": "address"
        }
      ],
      "name": "ManagerTransferred",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "pendingOwner",
          "type": "address"
        }
      ],
      "name": "OwnershipOffered",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "previousOwner",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "newOwner",
          "type": "address"
        }
      ],
      "name": "OwnershipTransferred",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "uint32",
          "name": "drawId",
          "type": "uint32"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "totalNetworkTicketSupply",
          "type": "uint256"
        }
      ],
      "name": "PrizeDistributionPushed",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "uint32",
          "name": "drawId",
          "type": "uint32"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "totalNetworkTicketSupply",
          "type": "uint256"
        }
      ],
      "name": "PrizeDistributionSet",
      "type": "event"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_drawId",
          "type": "uint32"
        },
        {
          "internalType": "uint256",
          "name": "_totalNetworkTicketSupply",
          "type": "uint256"
        }
      ],
      "name": "calculatePrizeDistribution",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint8",
              "name": "bitRangeSize",
              "type": "uint8"
            },
            {
              "internalType": "uint8",
              "name": "matchCardinality",
              "type": "uint8"
            },
            {
              "internalType": "uint32",
              "name": "startTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "endTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "maxPicksPerUser",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "expiryDuration",
              "type": "uint32"
            },
            {
              "internalType": "uint104",
              "name": "numberOfPicks",
              "type": "uint104"
            },
            {
              "internalType": "uint32[16]",
              "name": "tiers",
              "type": "uint32[16]"
            },
            {
              "internalType": "uint256",
              "name": "prize",
              "type": "uint256"
            }
          ],
          "internalType": "struct IPrizeDistributionSource.PrizeDistribution",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_drawId",
          "type": "uint32"
        },
        {
          "internalType": "uint256",
          "name": "_totalNetworkTicketSupply",
          "type": "uint256"
        },
        {
          "internalType": "uint32",
          "name": "_beaconPeriodSeconds",
          "type": "uint32"
        },
        {
          "internalType": "uint64",
          "name": "_drawTimestamp",
          "type": "uint64"
        }
      ],
      "name": "calculatePrizeDistributionWithDrawData",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint8",
              "name": "bitRangeSize",
              "type": "uint8"
            },
            {
              "internalType": "uint8",
              "name": "matchCardinality",
              "type": "uint8"
            },
            {
              "internalType": "uint32",
              "name": "startTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "endTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "maxPicksPerUser",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "expiryDuration",
              "type": "uint32"
            },
            {
              "internalType": "uint104",
              "name": "numberOfPicks",
              "type": "uint104"
            },
            {
              "internalType": "uint32[16]",
              "name": "tiers",
              "type": "uint32[16]"
            },
            {
              "internalType": "uint256",
              "name": "prize",
              "type": "uint256"
            }
          ],
          "internalType": "struct IPrizeDistributionSource.PrizeDistribution",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "claimOwnership",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "drawBuffer",
      "outputs": [
        {
          "internalType": "contract IDrawBuffer",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "manager",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "minPickCost",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "owner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "pendingOwner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "prizeDistributionBuffer",
      "outputs": [
        {
          "internalType": "contract IPrizeDistributionBuffer",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "prizeTierHistory",
      "outputs": [
        {
          "internalType": "contract IPrizeTierHistory",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_drawId",
          "type": "uint32"
        },
        {
          "internalType": "uint256",
          "name": "_totalNetworkTicketSupply",
          "type": "uint256"
        }
      ],
      "name": "pushPrizeDistribution",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint8",
              "name": "bitRangeSize",
              "type": "uint8"
            },
            {
              "internalType": "uint8",
              "name": "matchCardinality",
              "type": "uint8"
            },
            {
              "internalType": "uint32",
              "name": "startTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "endTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "maxPicksPerUser",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "expiryDuration",
              "type": "uint32"
            },
            {
              "internalType": "uint104",
              "name": "numberOfPicks",
              "type": "uint104"
            },
            {
              "internalType": "uint32[16]",
              "name": "tiers",
              "type": "uint32[16]"
            },
            {
              "internalType": "uint256",
              "name": "prize",
              "type": "uint256"
            }
          ],
          "internalType": "struct IPrizeDistributionSource.PrizeDistribution",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "renounceOwnership",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_newManager",
          "type": "address"
        }
      ],
      "name": "setManager",
      "outputs": [
        {
          "internalType": "bool",
          "name": "",
          "type": "bool"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint32",
          "name": "_drawId",
          "type": "uint32"
        },
        {
          "internalType": "uint256",
          "name": "_totalNetworkTicketSupply",
          "type": "uint256"
        }
      ],
      "name": "setPrizeDistribution",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint8",
              "name": "bitRangeSize",
              "type": "uint8"
            },
            {
              "internalType": "uint8",
              "name": "matchCardinality",
              "type": "uint8"
            },
            {
              "internalType": "uint32",
              "name": "startTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "endTimestampOffset",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "maxPicksPerUser",
              "type": "uint32"
            },
            {
              "internalType": "uint32",
              "name": "expiryDuration",
              "type": "uint32"
            },
            {
              "internalType": "uint104",
              "name": "numberOfPicks",
              "type": "uint104"
            },
            {
              "internalType": "uint32[16]",
              "name": "tiers",
              "type": "uint32[16]"
            },
            {
              "internalType": "uint256",
              "name": "prize",
              "type": "uint256"
            }
          ],
          "internalType": "struct IPrizeDistributionSource.PrizeDistribution",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "ticket",
      "outputs": [
        {
          "internalType": "contract ITicket",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_newOwner",
          "type": "address"
        }
      ],
      "name": "transferOwnership",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],
  "transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
  "receipt": {
    "to": null,
    "from": "0x4D40eb12430A57965cEe3015348d490C6156dF20",
    "contractAddress": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
    "transactionIndex": 0,
    "gasUsed": "1398224",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000100000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000001400000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000020000000000000000000000000000000000000000000000000000000000001000000",
    "blockHash": "0xc0054414f5319987134a33eac6466e859fba32332504675ee909d44c13e1ee31",
    "transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
    "logs": [
      {
        "transactionIndex": 0,
        "blockNumber": 14043055,
        "transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
        "address": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
        "topics": [
          "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
          "0x0000000000000000000000000000000000000000000000000000000000000000",
          "0x0000000000000000000000004d40eb12430a57965cee3015348d490c6156df20"
        ],
        "data": "0x",
        "logIndex": 0,
        "blockHash": "0xc0054414f5319987134a33eac6466e859fba32332504675ee909d44c13e1ee31"
      }
    ],
    "blockNumber": 14043055,
    "cumulativeGasUsed": "1398224",
    "status": 1,
    "byzantium": true
  },
  "args": [
    "0x4D40eb12430A57965cEe3015348d490C6156dF20",
    "0xC88f04D5D00367Ecd016228302a1eACFaB164DBA",
    "0x267DD4034830Bb4ba9314e0471C1dDFD79849777",
    "0x8e4F3098192948E342fB11ED7C4a23CD5A306973",
    "0x62BB4fc73094c83B5e952C2180B23fA7054954c4",
    1000000
  ],
  "numDeployments": 1,
  "solcInputHash": "45c8f80dfd4edb590489bcbaf8232d24",
  "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"contract IPrizeTierHistory\",\"name\":\"_prizeTierHistory\",\"type\":\"address\"},{\"internalType\":\"contract IDrawBuffer\",\"name\":\"_drawBuffer\",\"type\":\"address\"},{\"internalType\":\"contract IPrizeDistributionBuffer\",\"name\":\"_prizeDistributionBuffer\",\"type\":\"address\"},{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_minPickCost\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousManager\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newManager\",\"type\":\"address\"}],\"name\":\"ManagerTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pendingOwner\",\"type\":\"address\"}],\"name\":\"OwnershipOffered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"drawId\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalNetworkTicketSupply\",\"type\":\"uint256\"}],\"name\":\"PrizeDistributionPushed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"drawId\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalNetworkTicketSupply\",\"type\":\"uint256\"}],\"name\":\"PrizeDistributionSet\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_drawId\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"_totalNetworkTicketSupply\",\"type\":\"uint256\"}],\"name\":\"calculatePrizeDistribution\",\"outputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"bitRangeSize\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"matchCardinality\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"startTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"endTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxPicksPerUser\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"expiryDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint104\",\"name\":\"numberOfPicks\",\"type\":\"uint104\"},{\"internalType\":\"uint32[16]\",\"name\":\"tiers\",\"type\":\"uint32[16]\"},{\"internalType\":\"uint256\",\"name\":\"prize\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrizeDistributionSource.PrizeDistribution\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_drawId\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"_totalNetworkTicketSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_beaconPeriodSeconds\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"_drawTimestamp\",\"type\":\"uint64\"}],\"name\":\"calculatePrizeDistributionWithDrawData\",\"outputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"bitRangeSize\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"matchCardinality\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"startTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"endTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxPicksPerUser\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"expiryDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint104\",\"name\":\"numberOfPicks\",\"type\":\"uint104\"},{\"internalType\":\"uint32[16]\",\"name\":\"tiers\",\"type\":\"uint32[16]\"},{\"internalType\":\"uint256\",\"name\":\"prize\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrizeDistributionSource.PrizeDistribution\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"drawBuffer\",\"outputs\":[{\"internalType\":\"contract IDrawBuffer\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"manager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minPickCost\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"prizeDistributionBuffer\",\"outputs\":[{\"internalType\":\"contract IPrizeDistributionBuffer\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"prizeTierHistory\",\"outputs\":[{\"internalType\":\"contract IPrizeTierHistory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_drawId\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"_totalNetworkTicketSupply\",\"type\":\"uint256\"}],\"name\":\"pushPrizeDistribution\",\"outputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"bitRangeSize\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"matchCardinality\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"startTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"endTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxPicksPerUser\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"expiryDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint104\",\"name\":\"numberOfPicks\",\"type\":\"uint104\"},{\"internalType\":\"uint32[16]\",\"name\":\"tiers\",\"type\":\"uint32[16]\"},{\"internalType\":\"uint256\",\"name\":\"prize\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrizeDistributionSource.PrizeDistribution\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newManager\",\"type\":\"address\"}],\"name\":\"setManager\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_drawId\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"_totalNetworkTicketSupply\",\"type\":\"uint256\"}],\"name\":\"setPrizeDistribution\",\"outputs\":[{\"components\":[{\"internalType\":\"uint8\",\"name\":\"bitRangeSize\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"matchCardinality\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"startTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"endTimestampOffset\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxPicksPerUser\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"expiryDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint104\",\"name\":\"numberOfPicks\",\"type\":\"uint104\"},{\"internalType\":\"uint32[16]\",\"name\":\"tiers\",\"type\":\"uint32[16]\"},{\"internalType\":\"uint256\",\"name\":\"prize\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrizeDistributionSource.PrizeDistribution\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc.\",\"events\":{\"PrizeDistributionPushed(uint32,uint256)\":{\"params\":{\"drawId\":\"The draw id for which the prize dist was pushed\",\"totalNetworkTicketSupply\":\"The total network ticket supply that was used to compute the cardinality and portion of picks\"}},\"PrizeDistributionSet(uint32,uint256)\":{\"params\":{\"drawId\":\"The draw id for which the prize dist was set\",\"totalNetworkTicketSupply\":\"The total network ticket supply that was used to compute the cardinality and portion of picks\"}}},\"kind\":\"dev\",\"methods\":{\"calculatePrizeDistribution(uint32,uint256)\":{\"params\":{\"_drawId\":\"The draw id to pull from the Draw Buffer and Prize Tier History\",\"_totalNetworkTicketSupply\":\"The total of all ticket supplies across all prize pools in this network\"},\"returns\":{\"_0\":\"PrizeDistribution using info from the Draw for the given draw id, total network ticket supply, and PrizeTier for the draw.\"}},\"calculatePrizeDistributionWithDrawData(uint32,uint256,uint32,uint64)\":{\"params\":{\"_beaconPeriodSeconds\":\"The beacon period in seconds\",\"_drawId\":\"The draw from which to use the Draw and\",\"_drawTimestamp\":\"The timestamp at which the draw RNG request started.\",\"_totalNetworkTicketSupply\":\"The sum of all ticket supplies across all prize pools on the network\"},\"returns\":{\"_0\":\"A PrizeDistribution based on the given params and PrizeTier for the passed draw id\"}},\"claimOwnership()\":{\"details\":\"This function is only callable by the `_pendingOwner`.\"},\"manager()\":{\"returns\":{\"_0\":\"Current `_manager` address.\"}},\"pendingOwner()\":{\"returns\":{\"_0\":\"Current `_pendingOwner` address.\"}},\"pushPrizeDistribution(uint32,uint256)\":{\"params\":{\"_drawId\":\"The draw id to compute for\",\"_totalNetworkTicketSupply\":\"The total supply of tickets across all prize pools for the network that the ticket belongs to.\"},\"returns\":{\"_0\":\"The resulting Prize Distribution\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setManager(address)\":{\"details\":\"Throws if called by any account other than the owner.\",\"params\":{\"_newManager\":\"New _manager address.\"},\"returns\":{\"_0\":\"Boolean to indicate if the operation was successful or not.\"}},\"setPrizeDistribution(uint32,uint256)\":{\"params\":{\"_drawId\":\"The draw id to compute for\",\"_totalNetworkTicketSupply\":\"The total supply of tickets across all prize pools for the network that the ticket belongs to.\"},\"returns\":{\"_0\":\"The resulting Prize Distribution\"}},\"transferOwnership(address)\":{\"params\":{\"_newOwner\":\"Address to transfer ownership to.\"}}},\"title\":\"Prize Distribution Factory\",\"version\":1},\"userdoc\":{\"events\":{\"PrizeDistributionPushed(uint32,uint256)\":{\"notice\":\"Emitted when a new Prize Distribution is pushed.\"},\"PrizeDistributionSet(uint32,uint256)\":{\"notice\":\"Emitted when a Prize Distribution is set (overrides another)\"}},\"kind\":\"user\",\"methods\":{\"calculatePrizeDistribution(uint32,uint256)\":{\"notice\":\"Calculates what the prize distribution will be, given a draw id and total network ticket supply.\"},\"calculatePrizeDistributionWithDrawData(uint32,uint256,uint32,uint64)\":{\"notice\":\"Calculates what the prize distribution will be, given a draw id and total network ticket supply.\"},\"claimOwnership()\":{\"notice\":\"Allows the `_pendingOwner` address to finalize the transfer.\"},\"drawBuffer()\":{\"notice\":\"The draw buffer to pull the draw from\"},\"manager()\":{\"notice\":\"Gets current `_manager`.\"},\"minPickCost()\":{\"notice\":\"The minimum cost of each pick.  Used to calculate the cardinality.\"},\"owner()\":{\"notice\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"notice\":\"Gets current `_pendingOwner`.\"},\"prizeDistributionBuffer()\":{\"notice\":\"The prize distribution buffer to push and set.  This contract must be the manager or owner of the buffer.\"},\"prizeTierHistory()\":{\"notice\":\"The prize tier history to pull tier information from\"},\"pushPrizeDistribution(uint32,uint256)\":{\"notice\":\"Allows the owner or manager to push a new prize distribution onto the buffer. The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality.\"},\"renounceOwnership()\":{\"notice\":\"Renounce ownership of the contract.\"},\"setManager(address)\":{\"notice\":\"Set or change of manager.\"},\"setPrizeDistribution(uint32,uint256)\":{\"notice\":\"Allows the owner or manager to override an existing prize distribution in the buffer. The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality.\"},\"ticket()\":{\"notice\":\"The ticket whose average total supply will be measured to calculate the portion of picks\"},\"transferOwnership(address)\":{\"notice\":\"Allows current owner to set the `_pendingOwner` address.\"}},\"notice\":\"The Prize Distribution Factory populates a Prize Distribution Buffer for a prize pool.  It uses a Prize Tier History, Draw Buffer and Ticket to compute the correct prize distribution.  It automatically sets the cardinality based on the minPickCost and the total network ticket supply.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/PrizeDistributionFactory.sol\":\"PrizeDistributionFactory\"},\"evmVersion\":\"berlin\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n    /**\\n     * @dev Returns the amount of tokens in existence.\\n     */\\n    function totalSupply() external view returns (uint256);\\n\\n    /**\\n     * @dev Returns the amount of tokens owned by `account`.\\n     */\\n    function balanceOf(address account) external view returns (uint256);\\n\\n    /**\\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n     *\\n     * Returns a boolean value indicating whether the operation succeeded.\\n     *\\n     * Emits a {Transfer} event.\\n     */\\n    function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n    /**\\n     * @dev Returns the remaining number of tokens that `spender` will be\\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n     * zero by default.\\n     *\\n     * This value changes when {approve} or {transferFrom} are called.\\n     */\\n    function allowance(address owner, address spender) external view returns (uint256);\\n\\n    /**\\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n     *\\n     * Returns a boolean value indicating whether the operation succeeded.\\n     *\\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n     * that someone may use both the old and the new allowance by unfortunate\\n     * transaction ordering. One possible solution to mitigate this race\\n     * condition is to first reduce the spender's allowance to 0 and set the\\n     * desired value afterwards:\\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n     *\\n     * Emits an {Approval} event.\\n     */\\n    function approve(address spender, uint256 amount) external returns (bool);\\n\\n    /**\\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n     * allowance mechanism. `amount` is then deducted from the caller's\\n     * allowance.\\n     *\\n     * Returns a boolean value indicating whether the operation succeeded.\\n     *\\n     * Emits a {Transfer} event.\\n     */\\n    function transferFrom(\\n        address sender,\\n        address recipient,\\n        uint256 amount\\n    ) external returns (bool);\\n\\n    /**\\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n     * another (`to`).\\n     *\\n     * Note that `value` may be zero.\\n     */\\n    event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n    /**\\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n     * a call to {approve}. `value` is the new allowance.\\n     */\\n    event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x61437cb513a887a1bbad006e7b1c8b414478427d33de47c5600af3c748f108da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n    using Address for address;\\n\\n    function safeTransfer(\\n        IERC20 token,\\n        address to,\\n        uint256 value\\n    ) internal {\\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n    }\\n\\n    function safeTransferFrom(\\n        IERC20 token,\\n        address from,\\n        address to,\\n        uint256 value\\n    ) internal {\\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n    }\\n\\n    /**\\n     * @dev Deprecated. This function has issues similar to the ones found in\\n     * {IERC20-approve}, and its usage is discouraged.\\n     *\\n     * Whenever possible, use {safeIncreaseAllowance} and\\n     * {safeDecreaseAllowance} instead.\\n     */\\n    function safeApprove(\\n        IERC20 token,\\n        address spender,\\n        uint256 value\\n    ) internal {\\n        // safeApprove should only be called when setting an initial allowance,\\n        // or when resetting it to zero. To increase and decrease it, use\\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n        require(\\n            (value == 0) || (token.allowance(address(this), spender) == 0),\\n            \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n        );\\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n    }\\n\\n    function safeIncreaseAllowance(\\n        IERC20 token,\\n        address spender,\\n        uint256 value\\n    ) internal {\\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n    }\\n\\n    function safeDecreaseAllowance(\\n        IERC20 token,\\n        address spender,\\n        uint256 value\\n    ) internal {\\n        unchecked {\\n            uint256 oldAllowance = token.allowance(address(this), spender);\\n            require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n            uint256 newAllowance = oldAllowance - value;\\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n        }\\n    }\\n\\n    /**\\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\\n     * @param token The token targeted by the call.\\n     * @param data The call data (encoded using abi.encode or one of its variants).\\n     */\\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n        // the target address contains contract code and also asserts for success in the low-level call.\\n\\n        bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n        if (returndata.length > 0) {\\n            // Return data is optional\\n            require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n        }\\n    }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n    /**\\n     * @dev Returns true if `account` is a contract.\\n     *\\n     * [IMPORTANT]\\n     * ====\\n     * It is unsafe to assume that an address for which this function returns\\n     * false is an externally-owned account (EOA) and not a contract.\\n     *\\n     * Among others, `isContract` will return false for the following\\n     * types of addresses:\\n     *\\n     *  - an externally-owned account\\n     *  - a contract in construction\\n     *  - an address where a contract will be created\\n     *  - an address where a contract lived, but was destroyed\\n     * ====\\n     */\\n    function isContract(address account) internal view returns (bool) {\\n        // This method relies on extcodesize, which returns 0 for contracts in\\n        // construction, since the code is only stored at the end of the\\n        // constructor execution.\\n\\n        uint256 size;\\n        assembly {\\n            size := extcodesize(account)\\n        }\\n        return size > 0;\\n    }\\n\\n    /**\\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n     * `recipient`, forwarding all available gas and reverting on errors.\\n     *\\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n     * imposed by `transfer`, making them unable to receive funds via\\n     * `transfer`. {sendValue} removes this limitation.\\n     *\\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n     *\\n     * IMPORTANT: because control is transferred to `recipient`, care must be\\n     * taken to not create reentrancy vulnerabilities. Consider using\\n     * {ReentrancyGuard} or the\\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n     */\\n    function sendValue(address payable recipient, uint256 amount) internal {\\n        require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n        (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n        require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n    }\\n\\n    /**\\n     * @dev Performs a Solidity function call using a low level `call`. A\\n     * plain `call` is an unsafe replacement for a function call: use this\\n     * function instead.\\n     *\\n     * If `target` reverts with a revert reason, it is bubbled up by this\\n     * function (like regular Solidity function calls).\\n     *\\n     * Returns the raw returned data. To convert to the expected return value,\\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n     *\\n     * Requirements:\\n     *\\n     * - `target` must be a contract.\\n     * - calling `target` with `data` must not revert.\\n     *\\n     * _Available since v3.1._\\n     */\\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n        return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n     * `errorMessage` as a fallback revert reason when `target` reverts.\\n     *\\n     * _Available since v3.1._\\n     */\\n    function functionCall(\\n        address target,\\n        bytes memory data,\\n        string memory errorMessage\\n    ) internal returns (bytes memory) {\\n        return functionCallWithValue(target, data, 0, errorMessage);\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n     * but also transferring `value` wei to `target`.\\n     *\\n     * Requirements:\\n     *\\n     * - the calling contract must have an ETH balance of at least `value`.\\n     * - the called Solidity function must be `payable`.\\n     *\\n     * _Available since v3.1._\\n     */\\n    function functionCallWithValue(\\n        address target,\\n        bytes memory data,\\n        uint256 value\\n    ) internal returns (bytes memory) {\\n        return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\\n     *\\n     * _Available since v3.1._\\n     */\\n    function functionCallWithValue(\\n        address target,\\n        bytes memory data,\\n        uint256 value,\\n        string memory errorMessage\\n    ) internal returns (bytes memory) {\\n        require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n        require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\\n        return verifyCallResult(success, returndata, errorMessage);\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n     * but performing a static call.\\n     *\\n     * _Available since v3.3._\\n     */\\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n        return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n     * but performing a static call.\\n     *\\n     * _Available since v3.3._\\n     */\\n    function functionStaticCall(\\n        address target,\\n        bytes memory data,\\n        string memory errorMessage\\n    ) internal view returns (bytes memory) {\\n        require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n        (bool success, bytes memory returndata) = target.staticcall(data);\\n        return verifyCallResult(success, returndata, errorMessage);\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n     * but performing a delegate call.\\n     *\\n     * _Available since v3.4._\\n     */\\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n        return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n    }\\n\\n    /**\\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n     * but performing a delegate call.\\n     *\\n     * _Available since v3.4._\\n     */\\n    function functionDelegateCall(\\n        address target,\\n        bytes memory data,\\n        string memory errorMessage\\n    ) internal returns (bytes memory) {\\n        require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n        (bool success, bytes memory returndata) = target.delegatecall(data);\\n        return verifyCallResult(success, returndata, errorMessage);\\n    }\\n\\n    /**\\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n     * revert reason using the provided one.\\n     *\\n     * _Available since v4.3._\\n     */\\n    function verifyCallResult(\\n        bool success,\\n        bytes memory returndata,\\n        string memory errorMessage\\n    ) internal pure returns (bytes memory) {\\n        if (success) {\\n            return returndata;\\n        } else {\\n            // Look for revert reason and bubble it up if present\\n            if (returndata.length > 0) {\\n                // The easiest way to bubble the revert reason is using memory via assembly\\n\\n                assembly {\\n                    let returndata_size := mload(returndata)\\n                    revert(add(32, returndata), returndata_size)\\n                }\\n            } else {\\n                revert(errorMessage);\\n            }\\n        }\\n    }\\n}\\n\",\"keccak256\":\"0x51b758a8815ecc9596c66c37d56b1d33883a444631a3f916b9fe65cb863ef7c4\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n    /**\\n     * @dev Returns the downcasted uint224 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint224).\\n     *\\n     * Counterpart to Solidity's `uint224` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 224 bits\\n     */\\n    function toUint224(uint256 value) internal pure returns (uint224) {\\n        require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n        return uint224(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint128 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint128).\\n     *\\n     * Counterpart to Solidity's `uint128` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 128 bits\\n     */\\n    function toUint128(uint256 value) internal pure returns (uint128) {\\n        require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n        return uint128(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint96 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint96).\\n     *\\n     * Counterpart to Solidity's `uint96` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 96 bits\\n     */\\n    function toUint96(uint256 value) internal pure returns (uint96) {\\n        require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n        return uint96(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint64 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint64).\\n     *\\n     * Counterpart to Solidity's `uint64` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 64 bits\\n     */\\n    function toUint64(uint256 value) internal pure returns (uint64) {\\n        require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n        return uint64(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint32 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint32).\\n     *\\n     * Counterpart to Solidity's `uint32` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 32 bits\\n     */\\n    function toUint32(uint256 value) internal pure returns (uint32) {\\n        require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n        return uint32(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint16 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint16).\\n     *\\n     * Counterpart to Solidity's `uint16` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 16 bits\\n     */\\n    function toUint16(uint256 value) internal pure returns (uint16) {\\n        require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n        return uint16(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint8 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint8).\\n     *\\n     * Counterpart to Solidity's `uint8` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 8 bits.\\n     */\\n    function toUint8(uint256 value) internal pure returns (uint8) {\\n        require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n        return uint8(value);\\n    }\\n\\n    /**\\n     * @dev Converts a signed int256 into an unsigned uint256.\\n     *\\n     * Requirements:\\n     *\\n     * - input must be greater than or equal to 0.\\n     */\\n    function toUint256(int256 value) internal pure returns (uint256) {\\n        require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n        return uint256(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted int128 from int256, reverting on\\n     * overflow (when the input is less than smallest int128 or\\n     * greater than largest int128).\\n     *\\n     * Counterpart to Solidity's `int128` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 128 bits\\n     *\\n     * _Available since v3.1._\\n     */\\n    function toInt128(int256 value) internal pure returns (int128) {\\n        require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n        return int128(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted int64 from int256, reverting on\\n     * overflow (when the input is less than smallest int64 or\\n     * greater than largest int64).\\n     *\\n     * Counterpart to Solidity's `int64` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 64 bits\\n     *\\n     * _Available since v3.1._\\n     */\\n    function toInt64(int256 value) internal pure returns (int64) {\\n        require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n        return int64(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted int32 from int256, reverting on\\n     * overflow (when the input is less than smallest int32 or\\n     * greater than largest int32).\\n     *\\n     * Counterpart to Solidity's `int32` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 32 bits\\n     *\\n     * _Available since v3.1._\\n     */\\n    function toInt32(int256 value) internal pure returns (int32) {\\n        require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n        return int32(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted int16 from int256, reverting on\\n     * overflow (when the input is less than smallest int16 or\\n     * greater than largest int16).\\n     *\\n     * Counterpart to Solidity's `int16` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 16 bits\\n     *\\n     * _Available since v3.1._\\n     */\\n    function toInt16(int256 value) internal pure returns (int16) {\\n        require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n        return int16(value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted int8 from int256, reverting on\\n     * overflow (when the input is less than smallest int8 or\\n     * greater than largest int8).\\n     *\\n     * Counterpart to Solidity's `int8` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 8 bits.\\n     *\\n     * _Available since v3.1._\\n     */\\n    function toInt8(int256 value) internal pure returns (int8) {\\n        require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n        return int8(value);\\n    }\\n\\n    /**\\n     * @dev Converts an unsigned uint256 into a signed int256.\\n     *\\n     * Requirements:\\n     *\\n     * - input must be less than or equal to maxInt256.\\n     */\\n    function toInt256(uint256 value) internal pure returns (int256) {\\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n        require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n        return int256(value);\\n    }\\n}\\n\",\"keccak256\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"license\":\"MIT\"},\"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./Ownable.sol\\\";\\n\\n/**\\n * @title Abstract manageable contract that can be inherited by other contracts\\n * @notice Contract module based on Ownable which provides a basic access control mechanism, where\\n * there is an owner and a manager that can be granted exclusive access to specific functions.\\n *\\n * By default, the owner is the deployer of the contract.\\n *\\n * The owner account is set through a two steps process.\\n *      1. The current `owner` calls {transferOwnership} to set a `pendingOwner`\\n *      2. The `pendingOwner` calls {acceptOwnership} to accept the ownership transfer\\n *\\n * The manager account needs to be set using {setManager}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyManager`, which can be applied to your functions to restrict their use to\\n * the manager.\\n */\\nabstract contract Manageable is Ownable {\\n    address private _manager;\\n\\n    /**\\n     * @dev Emitted when `_manager` has been changed.\\n     * @param previousManager previous `_manager` address.\\n     * @param newManager new `_manager` address.\\n     */\\n    event ManagerTransferred(address indexed previousManager, address indexed newManager);\\n\\n    /* ============ External Functions ============ */\\n\\n    /**\\n     * @notice Gets current `_manager`.\\n     * @return Current `_manager` address.\\n     */\\n    function manager() public view virtual returns (address) {\\n        return _manager;\\n    }\\n\\n    /**\\n     * @notice Set or change of manager.\\n     * @dev Throws if called by any account other than the owner.\\n     * @param _newManager New _manager address.\\n     * @return Boolean to indicate if the operation was successful or not.\\n     */\\n    function setManager(address _newManager) external onlyOwner returns (bool) {\\n        return _setManager(_newManager);\\n    }\\n\\n    /* ============ Internal Functions ============ */\\n\\n    /**\\n     * @notice Set or change of manager.\\n     * @param _newManager New _manager address.\\n     * @return Boolean to indicate if the operation was successful or not.\\n     */\\n    function _setManager(address _newManager) private returns (bool) {\\n        address _previousManager = _manager;\\n\\n        require(_newManager != _previousManager, \\\"Manageable/existing-manager-address\\\");\\n\\n        _manager = _newManager;\\n\\n        emit ManagerTransferred(_previousManager, _newManager);\\n        return true;\\n    }\\n\\n    /* ============ Modifier Functions ============ */\\n\\n    /**\\n     * @dev Throws if called by any account other than the manager.\\n     */\\n    modifier onlyManager() {\\n        require(manager() == msg.sender, \\\"Manageable/caller-not-manager\\\");\\n        _;\\n    }\\n\\n    /**\\n     * @dev Throws if called by any account other than the manager or the owner.\\n     */\\n    modifier onlyManagerOrOwner() {\\n        require(manager() == msg.sender || owner() == msg.sender, \\\"Manageable/caller-not-manager-or-owner\\\");\\n        _;\\n    }\\n}\\n\",\"keccak256\":\"0xdd8ac008df192c6aa4df83e7037ab090970fda38e1f9fd712bc0ab5e0485fc04\",\"license\":\"GPL-3.0\"},\"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Abstract ownable contract that can be inherited by other contracts\\n * @notice Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner is the deployer of the contract.\\n *\\n * The owner account is set through a two steps process.\\n *      1. The current `owner` calls {transferOwnership} to set a `pendingOwner`\\n *      2. The `pendingOwner` calls {acceptOwnership} to accept the ownership transfer\\n *\\n * The manager account needs to be set using {setManager}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable {\\n    address private _owner;\\n    address private _pendingOwner;\\n\\n    /**\\n     * @dev Emitted when `_pendingOwner` has been changed.\\n     * @param pendingOwner new `_pendingOwner` address.\\n     */\\n    event OwnershipOffered(address indexed pendingOwner);\\n\\n    /**\\n     * @dev Emitted when `_owner` has been changed.\\n     * @param previousOwner previous `_owner` address.\\n     * @param newOwner new `_owner` address.\\n     */\\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n    /* ============ Deploy ============ */\\n\\n    /**\\n     * @notice Initializes the contract setting `_initialOwner` as the initial owner.\\n     * @param _initialOwner Initial owner of the contract.\\n     */\\n    constructor(address _initialOwner) {\\n        _setOwner(_initialOwner);\\n    }\\n\\n    /* ============ External Functions ============ */\\n\\n    /**\\n     * @notice Returns the address of the current owner.\\n     */\\n    function owner() public view virtual returns (address) {\\n        return _owner;\\n    }\\n\\n    /**\\n     * @notice Gets current `_pendingOwner`.\\n     * @return Current `_pendingOwner` address.\\n     */\\n    function pendingOwner() external view virtual returns (address) {\\n        return _pendingOwner;\\n    }\\n\\n    /**\\n     * @notice Renounce ownership of the contract.\\n     * @dev Leaves the contract without owner. It will not be possible to call\\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\\n     *\\n     * NOTE: Renouncing ownership will leave the contract without an owner,\\n     * thereby removing any functionality that is only available to the owner.\\n     */\\n    function renounceOwnership() external virtual onlyOwner {\\n        _setOwner(address(0));\\n    }\\n\\n    /**\\n    * @notice Allows current owner to set the `_pendingOwner` address.\\n    * @param _newOwner Address to transfer ownership to.\\n    */\\n    function transferOwnership(address _newOwner) external onlyOwner {\\n        require(_newOwner != address(0), \\\"Ownable/pendingOwner-not-zero-address\\\");\\n\\n        _pendingOwner = _newOwner;\\n\\n        emit OwnershipOffered(_newOwner);\\n    }\\n\\n    /**\\n    * @notice Allows the `_pendingOwner` address to finalize the transfer.\\n    * @dev This function is only callable by the `_pendingOwner`.\\n    */\\n    function claimOwnership() external onlyPendingOwner {\\n        _setOwner(_pendingOwner);\\n        _pendingOwner = address(0);\\n    }\\n\\n    /* ============ Internal Functions ============ */\\n\\n    /**\\n     * @notice Internal function to set the `_owner` of the contract.\\n     * @param _newOwner New `_owner` address.\\n     */\\n    function _setOwner(address _newOwner) private {\\n        address _oldOwner = _owner;\\n        _owner = _newOwner;\\n        emit OwnershipTransferred(_oldOwner, _newOwner);\\n    }\\n\\n    /* ============ Modifier Functions ============ */\\n\\n    /**\\n     * @dev Throws if called by any account other than the owner.\\n     */\\n    modifier onlyOwner() {\\n        require(owner() == msg.sender, \\\"Ownable/caller-not-owner\\\");\\n        _;\\n    }\\n\\n    /**\\n    * @dev Throws if called by any account other than the `pendingOwner`.\\n    */\\n    modifier onlyPendingOwner() {\\n        require(msg.sender == _pendingOwner, \\\"Ownable/caller-not-pendingOwner\\\");\\n        _;\\n    }\\n}\\n\",\"keccak256\":\"0xfd0fd374812c8af45f2633cc7cc4811ccb7bad0a3902a43aded35939eb4a00d1\",\"license\":\"GPL-3.0\"},\"@pooltogether/pooltogether-rng-contracts/contracts/RNGInterface.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity >=0.6.0;\\n\\n/// @title Random Number Generator Interface\\n/// @notice Provides an interface for requesting random numbers from 3rd-party RNG services (Chainlink VRF, Starkware VDF, etc..)\\ninterface RNGInterface {\\n\\n  /// @notice Emitted when a new request for a random number has been submitted\\n  /// @param requestId The indexed ID of the request used to get the results of the RNG service\\n  /// @param sender The indexed address of the sender of the request\\n  event RandomNumberRequested(uint32 indexed requestId, address indexed sender);\\n\\n  /// @notice Emitted when an existing request for a random number has been completed\\n  /// @param requestId The indexed ID of the request used to get the results of the RNG service\\n  /// @param randomNumber The random number produced by the 3rd-party service\\n  event RandomNumberCompleted(uint32 indexed requestId, uint256 randomNumber);\\n\\n  /// @notice Gets the last request id used by the RNG service\\n  /// @return requestId The last request id used in the last request\\n  function getLastRequestId() external view returns (uint32 requestId);\\n\\n  /// @notice Gets the Fee for making a Request against an RNG service\\n  /// @return feeToken The address of the token that is used to pay fees\\n  /// @return requestFee The fee required to be paid to make a request\\n  function getRequestFee() external view returns (address feeToken, uint256 requestFee);\\n\\n  /// @notice Sends a request for a random number to the 3rd-party service\\n  /// @dev Some services will complete the request immediately, others may have a time-delay\\n  /// @dev Some services require payment in the form of a token, such as $LINK for Chainlink VRF\\n  /// @return requestId The ID of the request used to get the results of the RNG service\\n  /// @return lockBlock The block number at which the RNG service will start generating time-delayed randomness.  The calling contract\\n  /// should \\\"lock\\\" all activity until the result is available via the `requestId`\\n  function requestRandomNumber() external returns (uint32 requestId, uint32 lockBlock);\\n\\n  /// @notice Checks if the request for randomness from the 3rd-party service has completed\\n  /// @dev For time-delayed requests, this function is used to check/confirm completion\\n  /// @param requestId The ID of the request used to get the results of the RNG service\\n  /// @return isCompleted True if the request has completed and a random number is available, false otherwise\\n  function isRequestComplete(uint32 requestId) external view returns (bool isCompleted);\\n\\n  /// @notice Gets the random number produced by the 3rd-party service\\n  /// @param requestId The ID of the request used to get the results of the RNG service\\n  /// @return randomNum The random number\\n  function randomNumber(uint32 requestId) external returns (uint256 randomNum);\\n}\\n\",\"keccak256\":\"0xf917c68439d7476cd226f475e8fce940e0cf1d32cb0ff12e8537072a07f2b1da\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/DrawBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@pooltogether/pooltogether-rng-contracts/contracts/RNGInterface.sol\\\";\\nimport \\\"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\\\";\\n\\nimport \\\"./interfaces/IDrawBeacon.sol\\\";\\nimport \\\"./interfaces/IDrawBuffer.sol\\\";\\n\\n\\n/**\\n  * @title  PoolTogether V4 DrawBeacon\\n  * @author PoolTogether Inc Team\\n  * @notice Manages RNG (random number generator) requests and pushing Draws onto DrawBuffer.\\n            The DrawBeacon has 3 major actions for requesting a random number: start, cancel and complete.\\n            To create a new Draw, the user requests a new random number from the RNG service.\\n            When the random number is available, the user can create the draw using the create() method\\n            which will push the draw onto the DrawBuffer.\\n            If the RNG service fails to deliver a rng, when the request timeout elapses, the user can cancel the request.\\n*/\\ncontract DrawBeacon is IDrawBeacon, Ownable {\\n    using SafeCast for uint256;\\n    using SafeERC20 for IERC20;\\n\\n    /* ============ Variables ============ */\\n\\n    /// @notice RNG contract interface\\n    RNGInterface internal rng;\\n\\n    /// @notice Current RNG Request\\n    RngRequest internal rngRequest;\\n\\n    /// @notice DrawBuffer address\\n    IDrawBuffer internal drawBuffer;\\n\\n    /**\\n     * @notice RNG Request Timeout.  In fact, this is really a \\\"complete draw\\\" timeout.\\n     * @dev If the rng completes the award can still be cancelled.\\n     */\\n    uint32 internal rngTimeout;\\n\\n    /// @notice Seconds between beacon period request\\n    uint32 internal beaconPeriodSeconds;\\n\\n    /// @notice Epoch timestamp when beacon period can start\\n    uint64 internal beaconPeriodStartedAt;\\n\\n    /**\\n     * @notice Next Draw ID to use when pushing a Draw onto DrawBuffer\\n     * @dev Starts at 1. This way we know that no Draw has been recorded at 0.\\n     */\\n    uint32 internal nextDrawId;\\n\\n    /* ============ Structs ============ */\\n\\n    /**\\n     * @notice RNG Request\\n     * @param id          RNG request ID\\n     * @param lockBlock   Block number that the RNG request is locked\\n     * @param requestedAt Time when RNG is requested\\n     */\\n    struct RngRequest {\\n        uint32 id;\\n        uint32 lockBlock;\\n        uint64 requestedAt;\\n    }\\n\\n    /* ============ Events ============ */\\n\\n    /**\\n     * @notice Emit when the DrawBeacon is deployed.\\n     * @param nextDrawId Draw ID at which the DrawBeacon should start. Can't be inferior to 1.\\n     * @param beaconPeriodStartedAt Timestamp when beacon period starts.\\n     */\\n    event Deployed(\\n        uint32 nextDrawId,\\n        uint64 beaconPeriodStartedAt\\n    );\\n\\n    /* ============ Modifiers ============ */\\n\\n    modifier requireDrawNotStarted() {\\n        _requireDrawNotStarted();\\n        _;\\n    }\\n\\n    modifier requireCanStartDraw() {\\n        require(_isBeaconPeriodOver(), \\\"DrawBeacon/beacon-period-not-over\\\");\\n        require(!isRngRequested(), \\\"DrawBeacon/rng-already-requested\\\");\\n        _;\\n    }\\n\\n    modifier requireCanCompleteRngRequest() {\\n        require(isRngRequested(), \\\"DrawBeacon/rng-not-requested\\\");\\n        require(isRngCompleted(), \\\"DrawBeacon/rng-not-complete\\\");\\n        _;\\n    }\\n\\n    /* ============ Constructor ============ */\\n\\n    /**\\n     * @notice Deploy the DrawBeacon smart contract.\\n     * @param _owner Address of the DrawBeacon owner\\n     * @param _drawBuffer The address of the draw buffer to push draws to\\n     * @param _rng The RNG service to use\\n     * @param _nextDrawId Draw ID at which the DrawBeacon should start. Can't be inferior to 1.\\n     * @param _beaconPeriodStart The starting timestamp of the beacon period.\\n     * @param _beaconPeriodSeconds The duration of the beacon period in seconds\\n     */\\n    constructor(\\n        address _owner,\\n        IDrawBuffer _drawBuffer,\\n        RNGInterface _rng,\\n        uint32 _nextDrawId,\\n        uint64 _beaconPeriodStart,\\n        uint32 _beaconPeriodSeconds,\\n        uint32 _rngTimeout\\n    ) Ownable(_owner) {\\n        require(_beaconPeriodStart > 0, \\\"DrawBeacon/beacon-period-greater-than-zero\\\");\\n        require(address(_rng) != address(0), \\\"DrawBeacon/rng-not-zero\\\");\\n        require(_nextDrawId >= 1, \\\"DrawBeacon/next-draw-id-gte-one\\\");\\n\\n        beaconPeriodStartedAt = _beaconPeriodStart;\\n        nextDrawId = _nextDrawId;\\n\\n        _setBeaconPeriodSeconds(_beaconPeriodSeconds);\\n        _setDrawBuffer(_drawBuffer);\\n        _setRngService(_rng);\\n        _setRngTimeout(_rngTimeout);\\n\\n        emit Deployed(_nextDrawId, _beaconPeriodStart);\\n        emit BeaconPeriodStarted(_beaconPeriodStart);\\n    }\\n\\n    /* ============ Public Functions ============ */\\n\\n    /**\\n     * @notice Returns whether the random number request has completed.\\n     * @return True if a random number request has completed, false otherwise.\\n     */\\n    function isRngCompleted() public view override returns (bool) {\\n        return rng.isRequestComplete(rngRequest.id);\\n    }\\n\\n    /**\\n     * @notice Returns whether a random number has been requested\\n     * @return True if a random number has been requested, false otherwise.\\n     */\\n    function isRngRequested() public view override returns (bool) {\\n        return rngRequest.id != 0;\\n    }\\n\\n    /**\\n     * @notice Returns whether the random number request has timed out.\\n     * @return True if a random number request has timed out, false otherwise.\\n     */\\n    function isRngTimedOut() public view override returns (bool) {\\n        if (rngRequest.requestedAt == 0) {\\n            return false;\\n        } else {\\n            return rngTimeout + rngRequest.requestedAt < _currentTime();\\n        }\\n    }\\n\\n    /* ============ External Functions ============ */\\n\\n    /// @inheritdoc IDrawBeacon\\n    function canStartDraw() external view override returns (bool) {\\n        return _isBeaconPeriodOver() && !isRngRequested();\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function canCompleteDraw() external view override returns (bool) {\\n        return isRngRequested() && isRngCompleted();\\n    }\\n\\n    /// @notice Calculates the next beacon start time, assuming all beacon periods have occurred between the last and now.\\n    /// @return The next beacon period start time\\n    function calculateNextBeaconPeriodStartTimeFromCurrentTime() external view returns (uint64) {\\n        return\\n            _calculateNextBeaconPeriodStartTime(\\n                beaconPeriodStartedAt,\\n                beaconPeriodSeconds,\\n                _currentTime()\\n            );\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function calculateNextBeaconPeriodStartTime(uint64 _time)\\n        external\\n        view\\n        override\\n        returns (uint64)\\n    {\\n        return\\n            _calculateNextBeaconPeriodStartTime(\\n                beaconPeriodStartedAt,\\n                beaconPeriodSeconds,\\n                _time\\n            );\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function cancelDraw() external override {\\n        require(isRngTimedOut(), \\\"DrawBeacon/rng-not-timedout\\\");\\n        uint32 requestId = rngRequest.id;\\n        uint32 lockBlock = rngRequest.lockBlock;\\n        delete rngRequest;\\n        emit DrawCancelled(requestId, lockBlock);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function completeDraw() external override requireCanCompleteRngRequest {\\n        uint256 randomNumber = rng.randomNumber(rngRequest.id);\\n        uint32 _nextDrawId = nextDrawId;\\n        uint64 _beaconPeriodStartedAt = beaconPeriodStartedAt;\\n        uint32 _beaconPeriodSeconds = beaconPeriodSeconds;\\n        uint64 _time = _currentTime();\\n\\n        // create Draw struct\\n        IDrawBeacon.Draw memory _draw = IDrawBeacon.Draw({\\n            winningRandomNumber: randomNumber,\\n            drawId: _nextDrawId,\\n            timestamp: rngRequest.requestedAt, // must use the startAward() timestamp to prevent front-running\\n            beaconPeriodStartedAt: _beaconPeriodStartedAt,\\n            beaconPeriodSeconds: _beaconPeriodSeconds\\n        });\\n\\n        drawBuffer.pushDraw(_draw);\\n\\n        // to avoid clock drift, we should calculate the start time based on the previous period start time.\\n        uint64 nextBeaconPeriodStartedAt = _calculateNextBeaconPeriodStartTime(\\n            _beaconPeriodStartedAt,\\n            _beaconPeriodSeconds,\\n            _time\\n        );\\n        beaconPeriodStartedAt = nextBeaconPeriodStartedAt;\\n        nextDrawId = _nextDrawId + 1;\\n\\n        // Reset the rngRequest state so Beacon period can start again.\\n        delete rngRequest;\\n\\n        emit DrawCompleted(randomNumber);\\n        emit BeaconPeriodStarted(nextBeaconPeriodStartedAt);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function beaconPeriodRemainingSeconds() external view override returns (uint64) {\\n        return _beaconPeriodRemainingSeconds();\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function beaconPeriodEndAt() external view override returns (uint64) {\\n        return _beaconPeriodEndAt();\\n    }\\n\\n    function getBeaconPeriodSeconds() external view returns (uint32) {\\n        return beaconPeriodSeconds;\\n    }\\n\\n    function getBeaconPeriodStartedAt() external view returns (uint64) {\\n        return beaconPeriodStartedAt;\\n    }\\n\\n    function getDrawBuffer() external view returns (IDrawBuffer) {\\n        return drawBuffer;\\n    }\\n\\n    function getNextDrawId() external view returns (uint32) {\\n        return nextDrawId;\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function getLastRngLockBlock() external view override returns (uint32) {\\n        return rngRequest.lockBlock;\\n    }\\n\\n    function getLastRngRequestId() external view override returns (uint32) {\\n        return rngRequest.id;\\n    }\\n\\n    function getRngService() external view returns (RNGInterface) {\\n        return rng;\\n    }\\n\\n    function getRngTimeout() external view returns (uint32) {\\n        return rngTimeout;\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function isBeaconPeriodOver() external view override returns (bool) {\\n        return _isBeaconPeriodOver();\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function setDrawBuffer(IDrawBuffer newDrawBuffer)\\n        external\\n        override\\n        onlyOwner\\n        returns (IDrawBuffer)\\n    {\\n        return _setDrawBuffer(newDrawBuffer);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function startDraw() external override requireCanStartDraw {\\n        (address feeToken, uint256 requestFee) = rng.getRequestFee();\\n\\n        if (feeToken != address(0) && requestFee > 0) {\\n            IERC20(feeToken).safeIncreaseAllowance(address(rng), requestFee);\\n        }\\n\\n        (uint32 requestId, uint32 lockBlock) = rng.requestRandomNumber();\\n        rngRequest.id = requestId;\\n        rngRequest.lockBlock = lockBlock;\\n        rngRequest.requestedAt = _currentTime();\\n\\n        emit DrawStarted(requestId, lockBlock);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function setBeaconPeriodSeconds(uint32 _beaconPeriodSeconds)\\n        external\\n        override\\n        onlyOwner\\n        requireDrawNotStarted\\n    {\\n        _setBeaconPeriodSeconds(_beaconPeriodSeconds);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function setRngTimeout(uint32 _rngTimeout) external override onlyOwner requireDrawNotStarted {\\n        _setRngTimeout(_rngTimeout);\\n    }\\n\\n    /// @inheritdoc IDrawBeacon\\n    function setRngService(RNGInterface _rngService)\\n        external\\n        override\\n        onlyOwner\\n        requireDrawNotStarted\\n    {\\n        _setRngService(_rngService);\\n    }\\n\\n    /**\\n     * @notice Sets the RNG service that the Prize Strategy is connected to\\n     * @param _rngService The address of the new RNG service interface\\n     */\\n    function _setRngService(RNGInterface _rngService) internal\\n    {\\n        rng = _rngService;\\n        emit RngServiceUpdated(_rngService);\\n    }\\n\\n    /* ============ Internal Functions ============ */\\n\\n    /**\\n     * @notice Calculates when the next beacon period will start\\n     * @param _beaconPeriodStartedAt The timestamp at which the beacon period started\\n     * @param _beaconPeriodSeconds The duration of the beacon period in seconds\\n     * @param _time The timestamp to use as the current time\\n     * @return The timestamp at which the next beacon period would start\\n     */\\n    function _calculateNextBeaconPeriodStartTime(\\n        uint64 _beaconPeriodStartedAt,\\n        uint32 _beaconPeriodSeconds,\\n        uint64 _time\\n    ) internal pure returns (uint64) {\\n        uint64 elapsedPeriods = (_time - _beaconPeriodStartedAt) / _beaconPeriodSeconds;\\n        return _beaconPeriodStartedAt + (elapsedPeriods * _beaconPeriodSeconds);\\n    }\\n\\n    /**\\n     * @notice returns the current time.  Used for testing.\\n     * @return The current time (block.timestamp)\\n     */\\n    function _currentTime() internal view virtual returns (uint64) {\\n        return uint64(block.timestamp);\\n    }\\n\\n    /**\\n     * @notice Returns the timestamp at which the beacon period ends\\n     * @return The timestamp at which the beacon period ends\\n     */\\n    function _beaconPeriodEndAt() internal view returns (uint64) {\\n        return beaconPeriodStartedAt + beaconPeriodSeconds;\\n    }\\n\\n    /**\\n     * @notice Returns the number of seconds remaining until the prize can be awarded.\\n     * @return The number of seconds remaining until the prize can be awarded.\\n     */\\n    function _beaconPeriodRemainingSeconds() internal view returns (uint64) {\\n        uint64 endAt = _beaconPeriodEndAt();\\n        uint64 time = _currentTime();\\n\\n        if (endAt <= time) {\\n            return 0;\\n        }\\n\\n        return endAt - time;\\n    }\\n\\n    /**\\n     * @notice Returns whether the beacon period is over.\\n     * @return True if the beacon period is over, false otherwise\\n     */\\n    function _isBeaconPeriodOver() internal view returns (bool) {\\n        return _beaconPeriodEndAt() <= _currentTime();\\n    }\\n\\n    /**\\n     * @notice Check to see draw is in progress.\\n     */\\n    function _requireDrawNotStarted() internal view {\\n        uint256 currentBlock = block.number;\\n\\n        require(\\n            rngRequest.lockBlock == 0 || currentBlock < rngRequest.lockBlock,\\n            \\\"DrawBeacon/rng-in-flight\\\"\\n        );\\n    }\\n\\n    /**\\n     * @notice Set global DrawBuffer variable.\\n     * @dev    All subsequent Draw requests/completions will be pushed to the new DrawBuffer.\\n     * @param _newDrawBuffer  DrawBuffer address\\n     * @return DrawBuffer\\n     */\\n    function _setDrawBuffer(IDrawBuffer _newDrawBuffer) internal returns (IDrawBuffer) {\\n        IDrawBuffer _previousDrawBuffer = drawBuffer;\\n        require(address(_newDrawBuffer) != address(0), \\\"DrawBeacon/draw-history-not-zero-address\\\");\\n\\n        require(\\n            address(_newDrawBuffer) != address(_previousDrawBuffer),\\n            \\\"DrawBeacon/existing-draw-history-address\\\"\\n        );\\n\\n        drawBuffer = _newDrawBuffer;\\n\\n        emit DrawBufferUpdated(_newDrawBuffer);\\n\\n        return _newDrawBuffer;\\n    }\\n\\n    /**\\n     * @notice Sets the beacon period in seconds.\\n     * @param _beaconPeriodSeconds The new beacon period in seconds.  Must be greater than zero.\\n     */\\n    function _setBeaconPeriodSeconds(uint32 _beaconPeriodSeconds) internal {\\n        require(_beaconPeriodSeconds > 0, \\\"DrawBeacon/beacon-period-greater-than-zero\\\");\\n        beaconPeriodSeconds = _beaconPeriodSeconds;\\n\\n        emit BeaconPeriodSecondsUpdated(_beaconPeriodSeconds);\\n    }\\n\\n    /**\\n     * @notice Sets the RNG request timeout in seconds.  This is the time that must elapsed before the RNG request can be cancelled and the pool unlocked.\\n     * @param _rngTimeout The RNG request timeout in seconds.\\n     */\\n    function _setRngTimeout(uint32 _rngTimeout) internal {\\n        require(_rngTimeout > 60, \\\"DrawBeacon/rng-timeout-gt-60-secs\\\");\\n        rngTimeout = _rngTimeout;\\n\\n        emit RngTimeoutSet(_rngTimeout);\\n    }\\n}\\n\",\"keccak256\":\"0xee85be5d2589d345c67eaed219009338addc41cf6ac3b74b1ebd8fdd7de404da\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/IControlledToken.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/** @title IControlledToken\\n  * @author PoolTogether Inc Team\\n  * @notice ERC20 Tokens with a controller for minting & burning.\\n*/\\ninterface IControlledToken is IERC20 {\\n\\n    /** \\n        @notice Interface to the contract responsible for controlling mint/burn\\n    */\\n    function controller() external view returns (address);\\n\\n    /** \\n      * @notice Allows the controller to mint tokens for a user account\\n      * @dev May be overridden to provide more granular control over minting\\n      * @param user Address of the receiver of the minted tokens\\n      * @param amount Amount of tokens to mint\\n    */\\n    function controllerMint(address user, uint256 amount) external;\\n\\n    /** \\n      * @notice Allows the controller to burn tokens from a user account\\n      * @dev May be overridden to provide more granular control over burning\\n      * @param user Address of the holder account to burn tokens from\\n      * @param amount Amount of tokens to burn\\n    */\\n    function controllerBurn(address user, uint256 amount) external;\\n\\n    /** \\n      * @notice Allows an operator via the controller to burn tokens on behalf of a user account\\n      * @dev May be overridden to provide more granular control over operator-burning\\n      * @param operator Address of the operator performing the burn action via the controller contract\\n      * @param user Address of the holder account to burn tokens from\\n      * @param amount Amount of tokens to burn\\n    */\\n    function controllerBurnFrom(\\n        address operator,\\n        address user,\\n        uint256 amount\\n    ) external;\\n}\\n\",\"keccak256\":\"0x90dceeec1eea6e49021e8db88b084f3f0c503c60b6f7e0bbecd2529ffde87ef3\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/IDrawBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@pooltogether/pooltogether-rng-contracts/contracts/RNGInterface.sol\\\";\\nimport \\\"./IDrawBuffer.sol\\\";\\n\\n/** @title  IDrawBeacon\\n  * @author PoolTogether Inc Team\\n  * @notice The DrawBeacon interface.\\n*/\\ninterface IDrawBeacon {\\n\\n    /// @notice Draw struct created every draw\\n    /// @param winningRandomNumber The random number returned from the RNG service\\n    /// @param drawId The monotonically increasing drawId for each draw\\n    /// @param timestamp Unix timestamp of the draw. Recorded when the draw is created by the DrawBeacon.\\n    /// @param beaconPeriodStartedAt Unix timestamp of when the draw started\\n    /// @param beaconPeriodSeconds Unix timestamp of the beacon draw period for this draw.\\n    struct Draw {\\n        uint256 winningRandomNumber;\\n        uint32 drawId;\\n        uint64 timestamp;\\n        uint64 beaconPeriodStartedAt;\\n        uint32 beaconPeriodSeconds;\\n    }\\n\\n    /**\\n     * @notice Emit when a new DrawBuffer has been set.\\n     * @param newDrawBuffer       The new DrawBuffer address\\n     */\\n    event DrawBufferUpdated(IDrawBuffer indexed newDrawBuffer);\\n\\n    /**\\n     * @notice Emit when a draw has opened.\\n     * @param startedAt Start timestamp\\n     */\\n    event BeaconPeriodStarted(uint64 indexed startedAt);\\n\\n    /**\\n     * @notice Emit when a draw has started.\\n     * @param rngRequestId  draw id\\n     * @param rngLockBlock  Block when draw becomes invalid\\n     */\\n    event DrawStarted(uint32 indexed rngRequestId, uint32 rngLockBlock);\\n\\n    /**\\n     * @notice Emit when a draw has been cancelled.\\n     * @param rngRequestId  draw id\\n     * @param rngLockBlock  Block when draw becomes invalid\\n     */\\n    event DrawCancelled(uint32 indexed rngRequestId, uint32 rngLockBlock);\\n\\n    /**\\n     * @notice Emit when a draw has been completed.\\n     * @param randomNumber  Random number generated from draw\\n     */\\n    event DrawCompleted(uint256 randomNumber);\\n\\n    /**\\n     * @notice Emit when a RNG service address is set.\\n     * @param rngService  RNG service address\\n     */\\n    event RngServiceUpdated(RNGInterface indexed rngService);\\n\\n    /**\\n     * @notice Emit when a draw timeout param is set.\\n     * @param rngTimeout  draw timeout param in seconds\\n     */\\n    event RngTimeoutSet(uint32 rngTimeout);\\n\\n    /**\\n     * @notice Emit when the drawPeriodSeconds is set.\\n     * @param drawPeriodSeconds Time between draw\\n     */\\n    event BeaconPeriodSecondsUpdated(uint32 drawPeriodSeconds);\\n\\n    /**\\n     * @notice Returns the number of seconds remaining until the beacon period can be complete.\\n     * @return The number of seconds remaining until the beacon period can be complete.\\n     */\\n    function beaconPeriodRemainingSeconds() external view returns (uint64);\\n\\n    /**\\n     * @notice Returns the timestamp at which the beacon period ends\\n     * @return The timestamp at which the beacon period ends.\\n     */\\n    function beaconPeriodEndAt() external view returns (uint64);\\n\\n    /**\\n     * @notice Returns whether a Draw can be started.\\n     * @return True if a Draw can be started, false otherwise.\\n     */\\n    function canStartDraw() external view returns (bool);\\n\\n    /**\\n     * @notice Returns whether a Draw can be completed.\\n     * @return True if a Draw can be completed, false otherwise.\\n     */\\n    function canCompleteDraw() external view returns (bool);\\n\\n    /**\\n     * @notice Calculates when the next beacon period will start.\\n     * @param time The timestamp to use as the current time\\n     * @return The timestamp at which the next beacon period would start\\n     */\\n    function calculateNextBeaconPeriodStartTime(uint64 time) external view returns (uint64);\\n\\n    /**\\n     * @notice Can be called by anyone to cancel the draw request if the RNG has timed out.\\n     */\\n    function cancelDraw() external;\\n\\n    /**\\n     * @notice Completes the Draw (RNG) request and pushes a Draw onto DrawBuffer.\\n     */\\n    function completeDraw() external;\\n\\n    /**\\n     * @notice Returns the block number that the current RNG request has been locked to.\\n     * @return The block number that the RNG request is locked to\\n     */\\n    function getLastRngLockBlock() external view returns (uint32);\\n\\n    /**\\n     * @notice Returns the current RNG Request ID.\\n     * @return The current Request ID\\n     */\\n    function getLastRngRequestId() external view returns (uint32);\\n\\n    /**\\n     * @notice Returns whether the beacon period is over\\n     * @return True if the beacon period is over, false otherwise\\n     */\\n    function isBeaconPeriodOver() external view returns (bool);\\n\\n    /**\\n     * @notice Returns whether the random number request has completed.\\n     * @return True if a random number request has completed, false otherwise.\\n     */\\n    function isRngCompleted() external view returns (bool);\\n\\n    /**\\n     * @notice Returns whether a random number has been requested\\n     * @return True if a random number has been requested, false otherwise.\\n     */\\n    function isRngRequested() external view returns (bool);\\n\\n    /**\\n     * @notice Returns whether the random number request has timed out.\\n     * @return True if a random number request has timed out, false otherwise.\\n     */\\n    function isRngTimedOut() external view returns (bool);\\n\\n    /**\\n     * @notice Allows the owner to set the beacon period in seconds.\\n     * @param beaconPeriodSeconds The new beacon period in seconds.  Must be greater than zero.\\n     */\\n    function setBeaconPeriodSeconds(uint32 beaconPeriodSeconds) external;\\n\\n    /**\\n     * @notice Allows the owner to set the RNG request timeout in seconds. This is the time that must elapsed before the RNG request can be cancelled and the pool unlocked.\\n     * @param rngTimeout The RNG request timeout in seconds.\\n     */\\n    function setRngTimeout(uint32 rngTimeout) external;\\n\\n    /**\\n     * @notice Sets the RNG service that the Prize Strategy is connected to\\n     * @param rngService The address of the new RNG service interface\\n     */\\n    function setRngService(RNGInterface rngService) external;\\n\\n    /**\\n     * @notice Starts the Draw process by starting random number request. The previous beacon period must have ended.\\n     * @dev The RNG-Request-Fee is expected to be held within this contract before calling this function\\n     */\\n    function startDraw() external;\\n\\n    /**\\n     * @notice Set global DrawBuffer variable.\\n     * @dev    All subsequent Draw requests/completions will be pushed to the new DrawBuffer.\\n     * @param newDrawBuffer DrawBuffer address\\n     * @return DrawBuffer\\n     */\\n    function setDrawBuffer(IDrawBuffer newDrawBuffer) external returns (IDrawBuffer);\\n}\\n\",\"keccak256\":\"0x43213073a191399978af2c7464c5e39af09efeeb503005d4e2a79705c40baa32\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/IDrawBuffer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"../interfaces/IDrawBeacon.sol\\\";\\n\\n/** @title  IDrawBuffer\\n  * @author PoolTogether Inc Team\\n  * @notice The DrawBuffer interface.\\n*/\\ninterface IDrawBuffer {\\n    /**\\n     * @notice Emit when a new draw has been created.\\n     * @param drawId Draw id\\n     * @param draw The Draw struct\\n     */\\n    event DrawSet(uint32 indexed drawId, IDrawBeacon.Draw draw);\\n\\n    /**\\n     * @notice Read a ring buffer cardinality\\n     * @return Ring buffer cardinality\\n     */\\n    function getBufferCardinality() external view returns (uint32);\\n\\n    /**\\n     * @notice Read a Draw from the draws ring buffer.\\n     * @dev    Read a Draw using the Draw.drawId to calculate position in the draws ring buffer.\\n     * @param drawId Draw.drawId\\n     * @return IDrawBeacon.Draw\\n     */\\n    function getDraw(uint32 drawId) external view returns (IDrawBeacon.Draw memory);\\n\\n    /**\\n     * @notice Read multiple Draws from the draws ring buffer.\\n     * @dev    Read multiple Draws using each drawId to calculate position in the draws ring buffer.\\n     * @param drawIds Array of drawIds\\n     * @return IDrawBeacon.Draw[]\\n     */\\n    function getDraws(uint32[] calldata drawIds) external view returns (IDrawBeacon.Draw[] memory);\\n\\n    /**\\n     * @notice Gets the number of Draws held in the draw ring buffer.\\n     * @dev If no Draws have been pushed, it will return 0.\\n     * @dev If the ring buffer is full, it will return the cardinality.\\n     * @dev Otherwise, it will return the NewestDraw index + 1.\\n     * @return Number of Draws held in the draw ring buffer.\\n     */\\n    function getDrawCount() external view returns (uint32);\\n\\n    /**\\n     * @notice Read newest Draw from draws ring buffer.\\n     * @dev    Uses the nextDrawIndex to calculate the most recently added Draw.\\n     * @return IDrawBeacon.Draw\\n     */\\n    function getNewestDraw() external view returns (IDrawBeacon.Draw memory);\\n\\n    /**\\n     * @notice Read oldest Draw from draws ring buffer.\\n     * @dev    Finds the oldest Draw by comparing and/or diffing totalDraws with the cardinality.\\n     * @return IDrawBeacon.Draw\\n     */\\n    function getOldestDraw() external view returns (IDrawBeacon.Draw memory);\\n\\n    /**\\n     * @notice Push Draw onto draws ring buffer history.\\n     * @dev    Push new draw onto draws history via authorized manager or owner.\\n     * @param draw IDrawBeacon.Draw\\n     * @return Draw.drawId\\n     */\\n    function pushDraw(IDrawBeacon.Draw calldata draw) external returns (uint32);\\n\\n    /**\\n     * @notice Set existing Draw in draws ring buffer with new parameters.\\n     * @dev    Updating a Draw should be used sparingly and only in the event an incorrect Draw parameter has been stored.\\n     * @param newDraw IDrawBeacon.Draw\\n     * @return Draw.drawId\\n     */\\n    function setDraw(IDrawBeacon.Draw calldata newDraw) external returns (uint32);\\n}\\n\",\"keccak256\":\"0x209ff20406b6b45ff5eff40af05c41a5d697441fc84e2e015e6828d874ccaa83\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionBuffer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"./IPrizeDistributionSource.sol\\\";\\n\\n/** @title  IPrizeDistributionBuffer\\n * @author PoolTogether Inc Team\\n * @notice The PrizeDistributionBuffer interface.\\n */\\ninterface IPrizeDistributionBuffer is IPrizeDistributionSource {\\n    /**\\n     * @notice Emit when PrizeDistribution is set.\\n     * @param drawId       Draw id\\n     * @param prizeDistribution IPrizeDistributionBuffer.PrizeDistribution\\n     */\\n    event PrizeDistributionSet(\\n        uint32 indexed drawId,\\n        IPrizeDistributionBuffer.PrizeDistribution prizeDistribution\\n    );\\n\\n    /**\\n     * @notice Read a ring buffer cardinality\\n     * @return Ring buffer cardinality\\n     */\\n    function getBufferCardinality() external view returns (uint32);\\n\\n    /**\\n     * @notice Read newest PrizeDistribution from prize distributions ring buffer.\\n     * @dev    Uses nextDrawIndex to calculate the most recently added PrizeDistribution.\\n     * @return prizeDistribution\\n     * @return drawId\\n     */\\n    function getNewestPrizeDistribution()\\n        external\\n        view\\n        returns (\\n            IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution,\\n            uint32 drawId\\n        );\\n\\n    /**\\n     * @notice Read oldest PrizeDistribution from prize distributions ring buffer.\\n     * @dev    Finds the oldest Draw by buffer.nextIndex and buffer.lastDrawId\\n     * @return prizeDistribution\\n     * @return drawId\\n     */\\n    function getOldestPrizeDistribution()\\n        external\\n        view\\n        returns (\\n            IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution,\\n            uint32 drawId\\n        );\\n\\n    /**\\n     * @notice Gets the PrizeDistributionBuffer for a drawId\\n     * @param drawId drawId\\n     * @return prizeDistribution\\n     */\\n    function getPrizeDistribution(uint32 drawId)\\n        external\\n        view\\n        returns (IPrizeDistributionBuffer.PrizeDistribution memory);\\n\\n    /**\\n     * @notice Gets the number of PrizeDistributions stored in the prize distributions ring buffer.\\n     * @dev If no Draws have been pushed, it will return 0.\\n     * @dev If the ring buffer is full, it will return the cardinality.\\n     * @dev Otherwise, it will return the NewestPrizeDistribution index + 1.\\n     * @return Number of PrizeDistributions stored in the prize distributions ring buffer.\\n     */\\n    function getPrizeDistributionCount() external view returns (uint32);\\n\\n    /**\\n     * @notice Adds new PrizeDistribution record to ring buffer storage.\\n     * @dev    Only callable by the owner or manager\\n     * @param drawId            Draw ID linked to PrizeDistribution parameters\\n     * @param prizeDistribution PrizeDistribution parameters struct\\n     */\\n    function pushPrizeDistribution(\\n        uint32 drawId,\\n        IPrizeDistributionBuffer.PrizeDistribution calldata prizeDistribution\\n    ) external returns (bool);\\n\\n    /**\\n     * @notice Sets existing PrizeDistribution with new PrizeDistribution parameters in ring buffer storage.\\n     * @dev    Retroactively updates an existing PrizeDistribution and should be thought of as a \\\"safety\\\"\\n               fallback. If the manager is setting invalid PrizeDistribution parameters the Owner can update\\n               the invalid parameters with correct parameters.\\n     * @return drawId\\n     */\\n    function setPrizeDistribution(\\n        uint32 drawId,\\n        IPrizeDistributionBuffer.PrizeDistribution calldata draw\\n    ) external returns (uint32);\\n}\\n\",\"keccak256\":\"0xa66b0d958502adda03e80924381bae30802f1c8d80823a9b787b8c66f6a7d835\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionSource.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\n/** @title IPrizeDistributionSource\\n * @author PoolTogether Inc Team\\n * @notice The PrizeDistributionSource interface.\\n */\\ninterface IPrizeDistributionSource {\\n    ///@notice PrizeDistribution struct created every draw\\n    ///@param bitRangeSize Decimal representation of bitRangeSize\\n    ///@param matchCardinality The number of numbers to consider in the 256 bit random number. Must be > 1 and < 256/bitRangeSize.\\n    ///@param startTimestampOffset The starting time offset in seconds from which Ticket balances are calculated.\\n    ///@param endTimestampOffset The end time offset in seconds from which Ticket balances are calculated.\\n    ///@param maxPicksPerUser Maximum number of picks a user can make in this draw\\n    ///@param expiryDuration Length of time in seconds the PrizeDistribution is valid for. Relative to the Draw.timestamp.\\n    ///@param numberOfPicks Number of picks this draw has (may vary across networks according to how much the network has contributed to the Reserve)\\n    ///@param tiers Array of prize tiers percentages, expressed in fraction form with base 1e9. Ordering: index0: grandPrize, index1: runnerUp, etc.\\n    ///@param prize Total prize amount available in this draw calculator for this draw (may vary from across networks)\\n    struct PrizeDistribution {\\n        uint8 bitRangeSize;\\n        uint8 matchCardinality;\\n        uint32 startTimestampOffset;\\n        uint32 endTimestampOffset;\\n        uint32 maxPicksPerUser;\\n        uint32 expiryDuration;\\n        uint104 numberOfPicks;\\n        uint32[16] tiers;\\n        uint256 prize;\\n    }\\n\\n    /**\\n     * @notice Gets PrizeDistribution list from array of drawIds\\n     * @param drawIds drawIds to get PrizeDistribution for\\n     * @return prizeDistributionList\\n     */\\n    function getPrizeDistributions(uint32[] calldata drawIds)\\n        external\\n        view\\n        returns (PrizeDistribution[] memory);\\n}\\n\",\"keccak256\":\"0x05ec47edc2684790a869a866576e7338229cc4eeafe1171bfc8cd7fa1c0cc9a0\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"../libraries/TwabLib.sol\\\";\\nimport \\\"./IControlledToken.sol\\\";\\n\\ninterface ITicket is IControlledToken {\\n    /**\\n     * @notice A struct containing details for an Account.\\n     * @param balance The current balance for an Account.\\n     * @param nextTwabIndex The next available index to store a new twab.\\n     * @param cardinality The number of recorded twabs (plus one!).\\n     */\\n    struct AccountDetails {\\n        uint224 balance;\\n        uint16 nextTwabIndex;\\n        uint16 cardinality;\\n    }\\n\\n    /**\\n     * @notice Combines account details with their twab history.\\n     * @param details The account details.\\n     * @param twabs The history of twabs for this account.\\n     */\\n    struct Account {\\n        AccountDetails details;\\n        ObservationLib.Observation[65535] twabs;\\n    }\\n\\n    /**\\n     * @notice Emitted when TWAB balance has been delegated to another user.\\n     * @param delegator Address of the delegator.\\n     * @param delegate Address of the delegate.\\n     */\\n    event Delegated(address indexed delegator, address indexed delegate);\\n\\n    /**\\n     * @notice Emitted when ticket is initialized.\\n     * @param name Ticket name (eg: PoolTogether Dai Ticket (Compound)).\\n     * @param symbol Ticket symbol (eg: PcDAI).\\n     * @param decimals Ticket decimals.\\n     * @param controller Token controller address.\\n     */\\n    event TicketInitialized(string name, string symbol, uint8 decimals, address indexed controller);\\n\\n    /**\\n     * @notice Emitted when a new TWAB has been recorded.\\n     * @param delegate The recipient of the ticket power (may be the same as the user).\\n     * @param newTwab Updated TWAB of a ticket holder after a successful TWAB recording.\\n     */\\n    event NewUserTwab(\\n        address indexed delegate,\\n        ObservationLib.Observation newTwab\\n    );\\n\\n    /**\\n     * @notice Emitted when a new total supply TWAB has been recorded.\\n     * @param newTotalSupplyTwab Updated TWAB of tickets total supply after a successful total supply TWAB recording.\\n     */\\n    event NewTotalSupplyTwab(ObservationLib.Observation newTotalSupplyTwab);\\n\\n    /**\\n     * @notice Retrieves the address of the delegate to whom `user` has delegated their tickets.\\n     * @dev Address of the delegate will be the zero address if `user` has not delegated their tickets.\\n     * @param user Address of the delegator.\\n     * @return Address of the delegate.\\n     */\\n    function delegateOf(address user) external view returns (address);\\n\\n    /**\\n    * @notice Delegate time-weighted average balances to an alternative address.\\n    * @dev    Transfers (including mints) trigger the storage of a TWAB in delegate(s) account, instead of the\\n              targetted sender and/or recipient address(s).\\n    * @dev    To reset the delegate, pass the zero address (0x000.000) as `to` parameter.\\n    * @dev Current delegate address should be different from the new delegate address `to`.\\n    * @param  to Recipient of delegated TWAB.\\n    */\\n    function delegate(address to) external;\\n\\n    /**\\n     * @notice Allows the controller to delegate on a users behalf.\\n     * @param user The user for whom to delegate\\n     * @param delegate The new delegate\\n     */\\n    function controllerDelegateFor(address user, address delegate) external;\\n\\n    /**\\n     * @notice Allows a user to delegate via signature\\n     * @param user The user who is delegating\\n     * @param delegate The new delegate\\n     * @param deadline The timestamp by which this must be submitted\\n     * @param v The v portion of the ECDSA sig\\n     * @param r The r portion of the ECDSA sig\\n     * @param s The s portion of the ECDSA sig\\n     */\\n    function delegateWithSignature(\\n        address user,\\n        address delegate,\\n        uint256 deadline,\\n        uint8 v,\\n        bytes32 r,\\n        bytes32 s\\n    ) external;\\n\\n    /**\\n     * @notice Gets a users twab context.  This is a struct with their balance, next twab index, and cardinality.\\n     * @param user The user for whom to fetch the TWAB context.\\n     * @return The TWAB context, which includes { balance, nextTwabIndex, cardinality }\\n     */\\n    function getAccountDetails(address user) external view returns (TwabLib.AccountDetails memory);\\n\\n    /**\\n     * @notice Gets the TWAB at a specific index for a user.\\n     * @param user The user for whom to fetch the TWAB.\\n     * @param index The index of the TWAB to fetch.\\n     * @return The TWAB, which includes the twab amount and the timestamp.\\n     */\\n    function getTwab(address user, uint16 index)\\n        external\\n        view\\n        returns (ObservationLib.Observation memory);\\n\\n    /**\\n     * @notice Retrieves `user` TWAB balance.\\n     * @param user Address of the user whose TWAB is being fetched.\\n     * @param timestamp Timestamp at which we want to retrieve the TWAB balance.\\n     * @return The TWAB balance at the given timestamp.\\n     */\\n    function getBalanceAt(address user, uint64 timestamp) external view returns (uint256);\\n\\n    /**\\n     * @notice Retrieves `user` TWAB balances.\\n     * @param user Address of the user whose TWABs are being fetched.\\n     * @param timestamps Timestamps range at which we want to retrieve the TWAB balances.\\n     * @return `user` TWAB balances.\\n     */\\n    function getBalancesAt(address user, uint64[] calldata timestamps)\\n        external\\n        view\\n        returns (uint256[] memory);\\n\\n    /**\\n     * @notice Retrieves the average balance held by a user for a given time frame.\\n     * @param user The user whose balance is checked.\\n     * @param startTime The start time of the time frame.\\n     * @param endTime The end time of the time frame.\\n     * @return The average balance that the user held during the time frame.\\n     */\\n    function getAverageBalanceBetween(\\n        address user,\\n        uint64 startTime,\\n        uint64 endTime\\n    ) external view returns (uint256);\\n\\n    /**\\n     * @notice Retrieves the average balances held by a user for a given time frame.\\n     * @param user The user whose balance is checked.\\n     * @param startTimes The start time of the time frame.\\n     * @param endTimes The end time of the time frame.\\n     * @return The average balance that the user held during the time frame.\\n     */\\n    function getAverageBalancesBetween(\\n        address user,\\n        uint64[] calldata startTimes,\\n        uint64[] calldata endTimes\\n    ) external view returns (uint256[] memory);\\n\\n    /**\\n     * @notice Retrieves the total supply TWAB balance at the given timestamp.\\n     * @param timestamp Timestamp at which we want to retrieve the total supply TWAB balance.\\n     * @return The total supply TWAB balance at the given timestamp.\\n     */\\n    function getTotalSupplyAt(uint64 timestamp) external view returns (uint256);\\n\\n    /**\\n     * @notice Retrieves the total supply TWAB balance between the given timestamps range.\\n     * @param timestamps Timestamps range at which we want to retrieve the total supply TWAB balance.\\n     * @return Total supply TWAB balances.\\n     */\\n    function getTotalSuppliesAt(uint64[] calldata timestamps)\\n        external\\n        view\\n        returns (uint256[] memory);\\n\\n    /**\\n     * @notice Retrieves the average total supply balance for a set of given time frames.\\n     * @param startTimes Array of start times.\\n     * @param endTimes Array of end times.\\n     * @return The average total supplies held during the time frame.\\n     */\\n    function getAverageTotalSuppliesBetween(\\n        uint64[] calldata startTimes,\\n        uint64[] calldata endTimes\\n    ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xb9f6423a8a9c7394941cb84723b82cc66c5f815d689dc0562e612ae4d9f1cc27\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/libraries/ExtendedSafeCastLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary ExtendedSafeCastLib {\\n\\n    /**\\n     * @dev Returns the downcasted uint104 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint104).\\n     *\\n     * Counterpart to Solidity's `uint104` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 104 bits\\n     */\\n    function toUint104(uint256 _value) internal pure returns (uint104) {\\n        require(_value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n        return uint104(_value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint208 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint208).\\n     *\\n     * Counterpart to Solidity's `uint208` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 208 bits\\n     */\\n    function toUint208(uint256 _value) internal pure returns (uint208) {\\n        require(_value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n        return uint208(_value);\\n    }\\n\\n    /**\\n     * @dev Returns the downcasted uint224 from uint256, reverting on\\n     * overflow (when the input is greater than largest uint224).\\n     *\\n     * Counterpart to Solidity's `uint224` operator.\\n     *\\n     * Requirements:\\n     *\\n     * - input must fit into 224 bits\\n     */\\n    function toUint224(uint256 _value) internal pure returns (uint224) {\\n        require(_value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n        return uint224(_value);\\n    }\\n}\\n\",\"keccak256\":\"0x1e8add7802f19dbf5957b4d921b2d7b5277f39c9e44505c0375e52f02134e434\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/libraries/ObservationLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\n\\nimport \\\"./OverflowSafeComparatorLib.sol\\\";\\nimport \\\"./RingBufferLib.sol\\\";\\n\\n/**\\n* @title Observation Library\\n* @notice This library allows one to store an array of timestamped values and efficiently binary search them.\\n* @dev Largely pulled from Uniswap V3 Oracle.sol: https://github.com/Uniswap/v3-core/blob/c05a0e2c8c08c460fb4d05cfdda30b3ad8deeaac/contracts/libraries/Oracle.sol\\n* @author PoolTogether Inc.\\n*/\\nlibrary ObservationLib {\\n    using OverflowSafeComparatorLib for uint32;\\n    using SafeCast for uint256;\\n\\n    /// @notice The maximum number of observations\\n    uint24 public constant MAX_CARDINALITY = 16777215; // 2**24\\n\\n    /**\\n    * @notice Observation, which includes an amount and timestamp.\\n    * @param amount `amount` at `timestamp`.\\n    * @param timestamp Recorded `timestamp`.\\n    */\\n    struct Observation {\\n        uint224 amount;\\n        uint32 timestamp;\\n    }\\n\\n    /**\\n    * @notice Fetches Observations `beforeOrAt` and `atOrAfter` a `_target`, eg: where [`beforeOrAt`, `atOrAfter`] is satisfied.\\n    * The result may be the same Observation, or adjacent Observations.\\n    * @dev The answer must be contained in the array used when the target is located within the stored Observation.\\n    * boundaries: older than the most recent Observation and younger, or the same age as, the oldest Observation.\\n    * @dev  If `_newestObservationIndex` is less than `_oldestObservationIndex`, it means that we've wrapped around the circular buffer.\\n    *       So the most recent observation will be at `_oldestObservationIndex + _cardinality - 1`, at the beginning of the circular buffer.\\n    * @param _observations List of Observations to search through.\\n    * @param _newestObservationIndex Index of the newest Observation. Right side of the circular buffer.\\n    * @param _oldestObservationIndex Index of the oldest Observation. Left side of the circular buffer.\\n    * @param _target Timestamp at which we are searching the Observation.\\n    * @param _cardinality Cardinality of the circular buffer we are searching through.\\n    * @param _time Timestamp at which we perform the binary search.\\n    * @return beforeOrAt Observation recorded before, or at, the target.\\n    * @return atOrAfter Observation recorded at, or after, the target.\\n    */\\n    function binarySearch(\\n        Observation[MAX_CARDINALITY] storage _observations,\\n        uint24 _newestObservationIndex,\\n        uint24 _oldestObservationIndex,\\n        uint32 _target,\\n        uint24 _cardinality,\\n        uint32 _time\\n    ) internal view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {\\n        uint256 leftSide = _oldestObservationIndex;\\n        uint256 rightSide = _newestObservationIndex < leftSide\\n            ? leftSide + _cardinality - 1\\n            : _newestObservationIndex;\\n        uint256 currentIndex;\\n\\n        while (true) {\\n            // We start our search in the middle of the `leftSide` and `rightSide`.\\n            // After each iteration, we narrow down the search to the left or the right side while still starting our search in the middle.\\n            currentIndex = (leftSide + rightSide) / 2;\\n\\n            beforeOrAt = _observations[uint24(RingBufferLib.wrap(currentIndex, _cardinality))];\\n            uint32 beforeOrAtTimestamp = beforeOrAt.timestamp;\\n\\n            // We've landed on an uninitialized timestamp, keep searching higher (more recently).\\n            if (beforeOrAtTimestamp == 0) {\\n                leftSide = currentIndex + 1;\\n                continue;\\n            }\\n\\n            atOrAfter = _observations[uint24(RingBufferLib.nextIndex(currentIndex, _cardinality))];\\n\\n            bool targetAtOrAfter = beforeOrAtTimestamp.lte(_target, _time);\\n\\n            // Check if we've found the corresponding Observation.\\n            if (targetAtOrAfter && _target.lte(atOrAfter.timestamp, _time)) {\\n                break;\\n            }\\n\\n            // If `beforeOrAtTimestamp` is greater than `_target`, then we keep searching lower. To the left of the current index.\\n            if (!targetAtOrAfter) {\\n                rightSide = currentIndex - 1;\\n            } else {\\n                // Otherwise, we keep searching higher. To the left of the current index.\\n                leftSide = currentIndex + 1;\\n            }\\n        }\\n    }\\n}\\n\",\"keccak256\":\"0x225592b42013fc0af60822e75bc047d53b42a5fcf15f2173cdc3b50bea334b0a\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/libraries/OverflowSafeComparatorLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\n/// @title OverflowSafeComparatorLib library to share comparator functions between contracts\\n/// @dev Code taken from Uniswap V3 Oracle.sol: https://github.com/Uniswap/v3-core/blob/3e88af408132fc957e3e406f65a0ce2b1ca06c3d/contracts/libraries/Oracle.sol\\n/// @author PoolTogether Inc.\\nlibrary OverflowSafeComparatorLib {\\n    /// @notice 32-bit timestamps comparator.\\n    /// @dev safe for 0 or 1 overflows, `_a` and `_b` must be chronologically before or equal to time.\\n    /// @param _a A comparison timestamp from which to determine the relative position of `_timestamp`.\\n    /// @param _b Timestamp to compare against `_a`.\\n    /// @param _timestamp A timestamp truncated to 32 bits.\\n    /// @return bool Whether `_a` is chronologically < `_b`.\\n    function lt(\\n        uint32 _a,\\n        uint32 _b,\\n        uint32 _timestamp\\n    ) internal pure returns (bool) {\\n        // No need to adjust if there hasn't been an overflow\\n        if (_a <= _timestamp && _b <= _timestamp) return _a < _b;\\n\\n        uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32;\\n        uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32;\\n\\n        return aAdjusted < bAdjusted;\\n    }\\n\\n    /// @notice 32-bit timestamps comparator.\\n    /// @dev safe for 0 or 1 overflows, `_a` and `_b` must be chronologically before or equal to time.\\n    /// @param _a A comparison timestamp from which to determine the relative position of `_timestamp`.\\n    /// @param _b Timestamp to compare against `_a`.\\n    /// @param _timestamp A timestamp truncated to 32 bits.\\n    /// @return bool Whether `_a` is chronologically <= `_b`.\\n    function lte(\\n        uint32 _a,\\n        uint32 _b,\\n        uint32 _timestamp\\n    ) internal pure returns (bool) {\\n\\n        // No need to adjust if there hasn't been an overflow\\n        if (_a <= _timestamp && _b <= _timestamp) return _a <= _b;\\n\\n        uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32;\\n        uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32;\\n\\n        return aAdjusted <= bAdjusted;\\n    }\\n\\n    /// @notice 32-bit timestamp subtractor\\n    /// @dev safe for 0 or 1 overflows, where `_a` and `_b` must be chronologically before or equal to time\\n    /// @param _a The subtraction left operand\\n    /// @param _b The subtraction right operand\\n    /// @param _timestamp The current time.  Expected to be chronologically after both.\\n    /// @return The difference between a and b, adjusted for overflow\\n    function checkedSub(\\n        uint32 _a,\\n        uint32 _b,\\n        uint32 _timestamp\\n    ) internal pure returns (uint32) {\\n        // No need to adjust if there hasn't been an overflow\\n\\n        if (_a <= _timestamp && _b <= _timestamp) return _a - _b;\\n\\n        uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32;\\n        uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32;\\n\\n        return uint32(aAdjusted - bAdjusted);\\n    }\\n}\\n\",\"keccak256\":\"0x20630cf89e7b92462946defe979fd0e69fa119841d55886121948ad810778c74\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/libraries/RingBufferLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nlibrary RingBufferLib {\\n    /**\\n    * @notice Returns wrapped TWAB index.\\n    * @dev  In order to navigate the TWAB circular buffer, we need to use the modulo operator.\\n    * @dev  For example, if `_index` is equal to 32 and the TWAB circular buffer is of `_cardinality` 32,\\n    *       it will return 0 and will point to the first element of the array.\\n    * @param _index Index used to navigate through the TWAB circular buffer.\\n    * @param _cardinality TWAB buffer cardinality.\\n    * @return TWAB index.\\n    */\\n    function wrap(uint256 _index, uint256 _cardinality) internal pure returns (uint256) {\\n        return _index % _cardinality;\\n    }\\n\\n    /**\\n    * @notice Computes the negative offset from the given index, wrapped by the cardinality.\\n    * @dev  We add `_cardinality` to `_index` to be able to offset even if `_amount` is superior to `_cardinality`.\\n    * @param _index The index from which to offset\\n    * @param _amount The number of indices to offset.  This is subtracted from the given index.\\n    * @param _cardinality The number of elements in the ring buffer\\n    * @return Offsetted index.\\n     */\\n    function offset(\\n        uint256 _index,\\n        uint256 _amount,\\n        uint256 _cardinality\\n    ) internal pure returns (uint256) {\\n        return wrap(_index + _cardinality - _amount, _cardinality);\\n    }\\n\\n    /// @notice Returns the index of the last recorded TWAB\\n    /// @param _nextIndex The next available twab index.  This will be recorded to next.\\n    /// @param _cardinality The cardinality of the TWAB history.\\n    /// @return The index of the last recorded TWAB\\n    function newestIndex(uint256 _nextIndex, uint256 _cardinality)\\n        internal\\n        pure\\n        returns (uint256)\\n    {\\n        if (_cardinality == 0) {\\n            return 0;\\n        }\\n\\n        return wrap(_nextIndex + _cardinality - 1, _cardinality);\\n    }\\n\\n    /// @notice Computes the ring buffer index that follows the given one, wrapped by cardinality\\n    /// @param _index The index to increment\\n    /// @param _cardinality The number of elements in the Ring Buffer\\n    /// @return The next index relative to the given index.  Will wrap around to 0 if the next index == cardinality\\n    function nextIndex(uint256 _index, uint256 _cardinality)\\n        internal\\n        pure\\n        returns (uint256)\\n    {\\n        return wrap(_index + 1, _cardinality);\\n    }\\n}\\n\",\"keccak256\":\"0x052e3bf6bfb30f32950e322c853589a8d153cf34f4b1ee292b17eb46f2ae656c\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-core/contracts/libraries/TwabLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"./ExtendedSafeCastLib.sol\\\";\\nimport \\\"./OverflowSafeComparatorLib.sol\\\";\\nimport \\\"./RingBufferLib.sol\\\";\\nimport \\\"./ObservationLib.sol\\\";\\n\\n/**\\n  * @title  PoolTogether V4 TwabLib (Library)\\n  * @author PoolTogether Inc Team\\n  * @dev    Time-Weighted Average Balance Library for ERC20 tokens.\\n  * @notice This TwabLib adds on-chain historical lookups to a user(s) time-weighted average balance.\\n            Each user is mapped to an Account struct containing the TWAB history (ring buffer) and\\n            ring buffer parameters. Every token.transfer() creates a new TWAB checkpoint. The new TWAB\\n            checkpoint is stored in the circular ring buffer, as either a new checkpoint or rewriting\\n            a previous checkpoint with new parameters. The TwabLib (using existing blocktimes of 1block/15sec)\\n            guarantees minimum 7.4 years of search history.\\n */\\nlibrary TwabLib {\\n    using OverflowSafeComparatorLib for uint32;\\n    using ExtendedSafeCastLib for uint256;\\n\\n    /**\\n      * @notice Sets max ring buffer length in the Account.twabs Observation list.\\n                As users transfer/mint/burn tickets new Observation checkpoints are\\n                recorded. The current max cardinality guarantees a seven year minimum,\\n                of accurate historical lookups with current estimates of 1 new block\\n                every 15 seconds - assuming each block contains a transfer to trigger an\\n                observation write to storage.\\n      * @dev    The user Account.AccountDetails.cardinality parameter can NOT exceed\\n                the max cardinality variable. Preventing \\\"corrupted\\\" ring buffer lookup\\n                pointers and new observation checkpoints.\\n\\n                The MAX_CARDINALITY in fact guarantees at least 7.4 years of records:\\n                If 14 = block time in seconds\\n                (2**24) * 14 = 234881024 seconds of history\\n                234881024 / (365 * 24 * 60 * 60) ~= 7.44 years\\n    */\\n    uint24 public constant MAX_CARDINALITY = 16777215; // 2**24\\n\\n    /** @notice Struct ring buffer parameters for single user Account\\n      * @param balance       Current balance for an Account\\n      * @param nextTwabIndex Next uninitialized or updatable ring buffer checkpoint storage slot\\n      * @param cardinality   Current total \\\"initialized\\\" ring buffer checkpoints for single user AccountDetails.\\n                             Used to set initial boundary conditions for an efficient binary search.\\n    */\\n    struct AccountDetails {\\n        uint208 balance;\\n        uint24 nextTwabIndex;\\n        uint24 cardinality;\\n    }\\n\\n    /// @notice Combines account details with their twab history\\n    /// @param details The account details\\n    /// @param twabs The history of twabs for this account\\n    struct Account {\\n        AccountDetails details;\\n        ObservationLib.Observation[MAX_CARDINALITY] twabs;\\n    }\\n\\n    /// @notice Increases an account's balance and records a new twab.\\n    /// @param _account The account whose balance will be increased\\n    /// @param _amount The amount to increase the balance by\\n    /// @param _currentTime The current time\\n    /// @return accountDetails The new AccountDetails\\n    /// @return twab The user's latest TWAB\\n    /// @return isNew Whether the TWAB is new\\n    function increaseBalance(\\n        Account storage _account,\\n        uint208 _amount,\\n        uint32 _currentTime\\n    )\\n        internal\\n        returns (\\n            AccountDetails memory accountDetails,\\n            ObservationLib.Observation memory twab,\\n            bool isNew\\n        )\\n    {\\n        AccountDetails memory _accountDetails = _account.details;\\n        (accountDetails, twab, isNew) = _nextTwab(_account.twabs, _accountDetails, _currentTime);\\n        accountDetails.balance = _accountDetails.balance + _amount;\\n    }\\n\\n    /** @notice Calculates the next TWAB checkpoint for an account with a decreasing balance.\\n     * @dev    With Account struct and amount decreasing calculates the next TWAB observable checkpoint.\\n     * @param _account        Account whose balance will be decreased\\n     * @param _amount         Amount to decrease the balance by\\n     * @param _revertMessage  Revert message for insufficient balance\\n     * @return accountDetails Updated Account.details struct\\n     * @return twab           TWAB observation (with decreasing average)\\n     * @return isNew          Whether TWAB is new or calling twice in the same block\\n     */\\n    function decreaseBalance(\\n        Account storage _account,\\n        uint208 _amount,\\n        string memory _revertMessage,\\n        uint32 _currentTime\\n    )\\n        internal\\n        returns (\\n            AccountDetails memory accountDetails,\\n            ObservationLib.Observation memory twab,\\n            bool isNew\\n        )\\n    {\\n        AccountDetails memory _accountDetails = _account.details;\\n\\n        require(_accountDetails.balance >= _amount, _revertMessage);\\n\\n        (accountDetails, twab, isNew) = _nextTwab(_account.twabs, _accountDetails, _currentTime);\\n        unchecked {\\n            accountDetails.balance -= _amount;\\n        }\\n    }\\n\\n    /** @notice Calculates the average balance held by a user for a given time frame.\\n      * @dev    Finds the average balance between start and end timestamp epochs.\\n                Validates the supplied end time is within the range of elapsed time i.e. less then timestamp of now.\\n      * @param _twabs          Individual user Observation recorded checkpoints passed as storage pointer\\n      * @param _accountDetails User AccountDetails struct loaded in memory\\n      * @param _startTime      Start of timestamp range as an epoch\\n      * @param _endTime        End of timestamp range as an epoch\\n      * @param _currentTime    Block.timestamp\\n      * @return Average balance of user held between epoch timestamps start and end\\n    */\\n    function getAverageBalanceBetween(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        uint32 _startTime,\\n        uint32 _endTime,\\n        uint32 _currentTime\\n    ) internal view returns (uint256) {\\n        uint32 endTime = _endTime > _currentTime ? _currentTime : _endTime;\\n\\n        return\\n            _getAverageBalanceBetween(_twabs, _accountDetails, _startTime, endTime, _currentTime);\\n    }\\n\\n    /// @notice Retrieves the oldest TWAB\\n    /// @param _twabs The storage array of twabs\\n    /// @param _accountDetails The TWAB account details\\n    /// @return index The index of the oldest TWAB in the twabs array\\n    /// @return twab The oldest TWAB\\n    function oldestTwab(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails\\n    ) internal view returns (uint24 index, ObservationLib.Observation memory twab) {\\n        index = _accountDetails.nextTwabIndex;\\n        twab = _twabs[index];\\n\\n        // If the TWAB is not initialized we go to the beginning of the TWAB circular buffer at index 0\\n        if (twab.timestamp == 0) {\\n            index = 0;\\n            twab = _twabs[0];\\n        }\\n    }\\n\\n    /// @notice Retrieves the newest TWAB\\n    /// @param _twabs The storage array of twabs\\n    /// @param _accountDetails The TWAB account details\\n    /// @return index The index of the newest TWAB in the twabs array\\n    /// @return twab The newest TWAB\\n    function newestTwab(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails\\n    ) internal view returns (uint24 index, ObservationLib.Observation memory twab) {\\n        index = uint24(RingBufferLib.newestIndex(_accountDetails.nextTwabIndex, MAX_CARDINALITY));\\n        twab = _twabs[index];\\n    }\\n\\n    /// @notice Retrieves amount at `_targetTime` timestamp\\n    /// @param _twabs List of TWABs to search through.\\n    /// @param _accountDetails Accounts details\\n    /// @param _targetTime Timestamp at which the reserved TWAB should be for.\\n    /// @return uint256 TWAB amount at `_targetTime`.\\n    function getBalanceAt(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        uint32 _targetTime,\\n        uint32 _currentTime\\n    ) internal view returns (uint256) {\\n        uint32 timeToTarget = _targetTime > _currentTime ? _currentTime : _targetTime;\\n        return _getBalanceAt(_twabs, _accountDetails, timeToTarget, _currentTime);\\n    }\\n\\n    /// @notice Calculates the average balance held by a user for a given time frame.\\n    /// @param _startTime The start time of the time frame.\\n    /// @param _endTime The end time of the time frame.\\n    /// @return The average balance that the user held during the time frame.\\n    function _getAverageBalanceBetween(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        uint32 _startTime,\\n        uint32 _endTime,\\n        uint32 _currentTime\\n    ) private view returns (uint256) {\\n        (uint24 oldestTwabIndex, ObservationLib.Observation memory oldTwab) = oldestTwab(\\n            _twabs,\\n            _accountDetails\\n        );\\n\\n        (uint24 newestTwabIndex, ObservationLib.Observation memory newTwab) = newestTwab(\\n            _twabs,\\n            _accountDetails\\n        );\\n\\n        ObservationLib.Observation memory startTwab = _calculateTwab(\\n            _twabs,\\n            _accountDetails,\\n            newTwab,\\n            oldTwab,\\n            newestTwabIndex,\\n            oldestTwabIndex,\\n            _startTime,\\n            _currentTime\\n        );\\n\\n        ObservationLib.Observation memory endTwab = _calculateTwab(\\n            _twabs,\\n            _accountDetails,\\n            newTwab,\\n            oldTwab,\\n            newestTwabIndex,\\n            oldestTwabIndex,\\n            _endTime,\\n            _currentTime\\n        );\\n\\n        // Difference in amount / time\\n        return (endTwab.amount - startTwab.amount) / OverflowSafeComparatorLib.checkedSub(endTwab.timestamp, startTwab.timestamp, _currentTime);\\n    }\\n\\n    /** @notice Searches TWAB history and calculate the difference between amount(s)/timestamp(s) to return average balance\\n                between the Observations closes to the supplied targetTime.\\n      * @param _twabs          Individual user Observation recorded checkpoints passed as storage pointer\\n      * @param _accountDetails User AccountDetails struct loaded in memory\\n      * @param _targetTime     Target timestamp to filter Observations in the ring buffer binary search\\n      * @param _currentTime    Block.timestamp\\n      * @return uint256 Time-weighted average amount between two closest observations.\\n    */\\n    function _getBalanceAt(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        uint32 _targetTime,\\n        uint32 _currentTime\\n    ) private view returns (uint256) {\\n        uint24 newestTwabIndex;\\n        ObservationLib.Observation memory afterOrAt;\\n        ObservationLib.Observation memory beforeOrAt;\\n        (newestTwabIndex, beforeOrAt) = newestTwab(_twabs, _accountDetails);\\n\\n        // If `_targetTime` is chronologically after the newest TWAB, we can simply return the current balance\\n        if (beforeOrAt.timestamp.lte(_targetTime, _currentTime)) {\\n            return _accountDetails.balance;\\n        }\\n\\n        uint24 oldestTwabIndex;\\n        // Now, set before to the oldest TWAB\\n        (oldestTwabIndex, beforeOrAt) = oldestTwab(_twabs, _accountDetails);\\n\\n        // If `_targetTime` is chronologically before the oldest TWAB, we can early return\\n        if (_targetTime.lt(beforeOrAt.timestamp, _currentTime)) {\\n            return 0;\\n        }\\n\\n        // Otherwise, we perform the `binarySearch`\\n        (beforeOrAt, afterOrAt) = ObservationLib.binarySearch(\\n            _twabs,\\n            newestTwabIndex,\\n            oldestTwabIndex,\\n            _targetTime,\\n            _accountDetails.cardinality,\\n            _currentTime\\n        );\\n\\n        // Sum the difference in amounts and divide by the difference in timestamps.\\n        // The time-weighted average balance uses time measured between two epoch timestamps as\\n        // a constaint on the measurement when calculating the time weighted average balance.\\n        return\\n            (afterOrAt.amount - beforeOrAt.amount) / OverflowSafeComparatorLib.checkedSub(afterOrAt.timestamp, beforeOrAt.timestamp, _currentTime);\\n    }\\n\\n    /** @notice Calculates a user TWAB for a target timestamp using the historical TWAB records.\\n                The balance is linearly interpolated: amount differences / timestamp differences\\n                using the simple (after.amount - before.amount / end.timestamp - start.timestamp) formula.\\n    /** @dev    Binary search in _calculateTwab fails when searching out of bounds. Thus, before\\n                searching we exclude target timestamps out of range of newest/oldest TWAB(s).\\n                IF a search is before or after the range we \\\"extrapolate\\\" a Observation from the expected state.\\n      * @param _twabs           Individual user Observation recorded checkpoints passed as storage pointer\\n      * @param _accountDetails  User AccountDetails struct loaded in memory\\n      * @param _newestTwab      Newest TWAB in history (end of ring buffer)\\n      * @param _oldestTwab      Olderst TWAB in history (end of ring buffer)\\n      * @param _newestTwabIndex Pointer in ring buffer to newest TWAB\\n      * @param _oldestTwabIndex Pointer in ring buffer to oldest TWAB\\n      * @param _targetTimestamp Epoch timestamp to calculate for time (T) in the TWAB\\n      * @param _time            Block.timestamp\\n      * @return accountDetails Updated Account.details struct\\n    */\\n    function _calculateTwab(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        ObservationLib.Observation memory _newestTwab,\\n        ObservationLib.Observation memory _oldestTwab,\\n        uint24 _newestTwabIndex,\\n        uint24 _oldestTwabIndex,\\n        uint32 _targetTimestamp,\\n        uint32 _time\\n    ) private view returns (ObservationLib.Observation memory) {\\n        // If `_targetTimestamp` is chronologically after the newest TWAB, we extrapolate a new one\\n        if (_newestTwab.timestamp.lt(_targetTimestamp, _time)) {\\n            return _computeNextTwab(_newestTwab, _accountDetails.balance, _targetTimestamp);\\n        }\\n\\n        if (_newestTwab.timestamp == _targetTimestamp) {\\n            return _newestTwab;\\n        }\\n\\n        if (_oldestTwab.timestamp == _targetTimestamp) {\\n            return _oldestTwab;\\n        }\\n\\n        // If `_targetTimestamp` is chronologically before the oldest TWAB, we create a zero twab\\n        if (_targetTimestamp.lt(_oldestTwab.timestamp, _time)) {\\n            return ObservationLib.Observation({ amount: 0, timestamp: _targetTimestamp });\\n        }\\n\\n        // Otherwise, both timestamps must be surrounded by twabs.\\n        (\\n            ObservationLib.Observation memory beforeOrAtStart,\\n            ObservationLib.Observation memory afterOrAtStart\\n        ) = ObservationLib.binarySearch(\\n                _twabs,\\n                _newestTwabIndex,\\n                _oldestTwabIndex,\\n                _targetTimestamp,\\n                _accountDetails.cardinality,\\n                _time\\n            );\\n\\n        uint224 heldBalance = (afterOrAtStart.amount - beforeOrAtStart.amount) /\\n            OverflowSafeComparatorLib.checkedSub(afterOrAtStart.timestamp, beforeOrAtStart.timestamp, _time);\\n\\n        return _computeNextTwab(beforeOrAtStart, heldBalance, _targetTimestamp);\\n    }\\n\\n    /**\\n     * @notice Calculates the next TWAB using the newestTwab and updated balance.\\n     * @dev    Storage of the TWAB obersation is managed by the calling function and not _computeNextTwab.\\n     * @param _currentTwab    Newest Observation in the Account.twabs list\\n     * @param _currentBalance User balance at time of most recent (newest) checkpoint write\\n     * @param _time           Current block.timestamp\\n     * @return TWAB Observation\\n     */\\n    function _computeNextTwab(\\n        ObservationLib.Observation memory _currentTwab,\\n        uint224 _currentBalance,\\n        uint32 _time\\n    ) private pure returns (ObservationLib.Observation memory) {\\n        // New twab amount = last twab amount (or zero) + (current amount * elapsed seconds)\\n        return\\n            ObservationLib.Observation({\\n                amount: _currentTwab.amount +\\n                    _currentBalance *\\n                    (_time.checkedSub(_currentTwab.timestamp, _time)),\\n                timestamp: _time\\n            });\\n    }\\n\\n    /// @notice Sets a new TWAB Observation at the next available index and returns the new account details.\\n    /// @dev Note that if _currentTime is before the last observation timestamp, it appears as an overflow\\n    /// @param _twabs The twabs array to insert into\\n    /// @param _accountDetails The current account details\\n    /// @param _currentTime The current time\\n    /// @return accountDetails The new account details\\n    /// @return twab The newest twab (may or may not be brand-new)\\n    /// @return isNew Whether the newest twab was created by this call\\n    function _nextTwab(\\n        ObservationLib.Observation[MAX_CARDINALITY] storage _twabs,\\n        AccountDetails memory _accountDetails,\\n        uint32 _currentTime\\n    )\\n        private\\n        returns (\\n            AccountDetails memory accountDetails,\\n            ObservationLib.Observation memory twab,\\n            bool isNew\\n        )\\n    {\\n        (, ObservationLib.Observation memory _newestTwab) = newestTwab(_twabs, _accountDetails);\\n\\n        // if we're in the same block, return\\n        if (_newestTwab.timestamp == _currentTime) {\\n            return (_accountDetails, _newestTwab, false);\\n        }\\n\\n        ObservationLib.Observation memory newTwab = _computeNextTwab(\\n            _newestTwab,\\n            _accountDetails.balance,\\n            _currentTime\\n        );\\n\\n        _twabs[_accountDetails.nextTwabIndex] = newTwab;\\n\\n        AccountDetails memory nextAccountDetails = push(_accountDetails);\\n\\n        return (nextAccountDetails, newTwab, true);\\n    }\\n\\n    /// @notice \\\"Pushes\\\" a new element on the AccountDetails ring buffer, and returns the new AccountDetails\\n    /// @param _accountDetails The account details from which to pull the cardinality and next index\\n    /// @return The new AccountDetails\\n    function push(AccountDetails memory _accountDetails)\\n        internal\\n        pure\\n        returns (AccountDetails memory)\\n    {\\n        _accountDetails.nextTwabIndex = uint24(\\n            RingBufferLib.nextIndex(_accountDetails.nextTwabIndex, MAX_CARDINALITY)\\n        );\\n\\n        // Prevent the Account specific cardinality from exceeding the MAX_CARDINALITY.\\n        // The ring buffer length is limited by MAX_CARDINALITY. IF the account.cardinality\\n        // exceeds the max cardinality, new observations would be incorrectly set or the\\n        // observation would be out of \\\"bounds\\\" of the ring buffer. Once reached the\\n        // AccountDetails.cardinality will continue to be equal to max cardinality.\\n        if (_accountDetails.cardinality < MAX_CARDINALITY) {\\n            _accountDetails.cardinality += 1;\\n        }\\n\\n        return _accountDetails;\\n    }\\n}\\n\",\"keccak256\":\"0x446d8221329601d40464981a50a0e31f3fd48da0ebf0fea646c5a089ccfbdff4\",\"license\":\"GPL-3.0\"},\"contracts/PrizeDistributionFactory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionBuffer.sol\\\";\\nimport \\\"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\\\";\\n\\nimport \\\"./interfaces/IPrizeTierHistory.sol\\\";\\n\\n/**\\n * @title Prize Distribution Factory\\n * @author PoolTogether Inc.\\n * @notice The Prize Distribution Factory populates a Prize Distribution Buffer for a prize pool.  It uses a Prize Tier History, Draw Buffer and Ticket\\n * to compute the correct prize distribution.  It automatically sets the cardinality based on the minPickCost and the total network ticket supply.\\n */\\ncontract PrizeDistributionFactory is Manageable {\\n    using ExtendedSafeCastLib for uint256;\\n\\n    /// @notice Emitted when a new Prize Distribution is pushed.\\n    /// @param drawId The draw id for which the prize dist was pushed\\n    /// @param totalNetworkTicketSupply The total network ticket supply that was used to compute the cardinality and portion of picks\\n    event PrizeDistributionPushed(uint32 indexed drawId, uint256 totalNetworkTicketSupply);\\n\\n    /// @notice Emitted when a Prize Distribution is set (overrides another)\\n    /// @param drawId The draw id for which the prize dist was set\\n    /// @param totalNetworkTicketSupply The total network ticket supply that was used to compute the cardinality and portion of picks\\n    event PrizeDistributionSet(uint32 indexed drawId, uint256 totalNetworkTicketSupply);\\n\\n    /// @notice The prize tier history to pull tier information from\\n    IPrizeTierHistory public immutable prizeTierHistory;\\n\\n    /// @notice The draw buffer to pull the draw from\\n    IDrawBuffer public immutable drawBuffer;\\n\\n    /// @notice The prize distribution buffer to push and set.  This contract must be the manager or owner of the buffer.\\n    IPrizeDistributionBuffer public immutable prizeDistributionBuffer;\\n\\n    /// @notice The ticket whose average total supply will be measured to calculate the portion of picks\\n    ITicket public immutable ticket;\\n\\n    /// @notice The minimum cost of each pick.  Used to calculate the cardinality.\\n    uint256 public immutable minPickCost;\\n\\n    constructor(\\n        address _owner,\\n        IPrizeTierHistory _prizeTierHistory,\\n        IDrawBuffer _drawBuffer,\\n        IPrizeDistributionBuffer _prizeDistributionBuffer,\\n        ITicket _ticket,\\n        uint256 _minPickCost\\n    ) Ownable(_owner) {\\n        require(_owner != address(0), \\\"PDC/owner-zero\\\");\\n        require(address(_prizeTierHistory) != address(0), \\\"PDC/pth-zero\\\");\\n        require(address(_drawBuffer) != address(0), \\\"PDC/db-zero\\\");\\n        require(address(_prizeDistributionBuffer) != address(0), \\\"PDC/pdb-zero\\\");\\n        require(address(_ticket) != address(0), \\\"PDC/ticket-zero\\\");\\n        require(_minPickCost > 0, \\\"PDC/pick-cost-gt-zero\\\");\\n\\n        minPickCost = _minPickCost;\\n        prizeTierHistory = _prizeTierHistory;\\n        drawBuffer = _drawBuffer;\\n        prizeDistributionBuffer = _prizeDistributionBuffer;\\n        ticket = _ticket;\\n    }\\n\\n    /**\\n     * @notice Allows the owner or manager to push a new prize distribution onto the buffer.\\n     * The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality.\\n     * @param _drawId The draw id to compute for\\n     * @param _totalNetworkTicketSupply The total supply of tickets across all prize pools for the network that the ticket belongs to.\\n     * @return The resulting Prize Distribution\\n     */\\n    function pushPrizeDistribution(uint32 _drawId, uint256 _totalNetworkTicketSupply)\\n        external\\n        onlyManagerOrOwner\\n        returns (IPrizeDistributionBuffer.PrizeDistribution memory)\\n    {\\n        IPrizeDistributionBuffer.PrizeDistribution\\n            memory prizeDistribution = calculatePrizeDistribution(\\n                _drawId,\\n                _totalNetworkTicketSupply\\n            );\\n        prizeDistributionBuffer.pushPrizeDistribution(_drawId, prizeDistribution);\\n\\n        emit PrizeDistributionPushed(_drawId, _totalNetworkTicketSupply);\\n\\n        return prizeDistribution;\\n    }\\n\\n    /**\\n     * @notice Allows the owner or manager to override an existing prize distribution in the buffer.\\n     * The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality.\\n     * @param _drawId The draw id to compute for\\n     * @param _totalNetworkTicketSupply The total supply of tickets across all prize pools for the network that the ticket belongs to.\\n     * @return The resulting Prize Distribution\\n     */\\n    function setPrizeDistribution(uint32 _drawId, uint256 _totalNetworkTicketSupply)\\n        external\\n        onlyOwner\\n        returns (IPrizeDistributionBuffer.PrizeDistribution memory)\\n    {\\n        IPrizeDistributionBuffer.PrizeDistribution\\n            memory prizeDistribution = calculatePrizeDistribution(\\n                _drawId,\\n                _totalNetworkTicketSupply\\n            );\\n        prizeDistributionBuffer.setPrizeDistribution(_drawId, prizeDistribution);\\n\\n        emit PrizeDistributionSet(_drawId, _totalNetworkTicketSupply);\\n\\n        return prizeDistribution;\\n    }\\n\\n    /**\\n     * @notice Calculates what the prize distribution will be, given a draw id and total network ticket supply.\\n     * @param _drawId The draw id to pull from the Draw Buffer and Prize Tier History\\n     * @param _totalNetworkTicketSupply The total of all ticket supplies across all prize pools in this network\\n     * @return PrizeDistribution using info from the Draw for the given draw id, total network ticket supply, and PrizeTier for the draw.\\n     */\\n    function calculatePrizeDistribution(uint32 _drawId, uint256 _totalNetworkTicketSupply)\\n        public\\n        view\\n        virtual\\n        returns (IPrizeDistributionBuffer.PrizeDistribution memory)\\n    {\\n        IDrawBeacon.Draw memory draw = drawBuffer.getDraw(_drawId);\\n        return\\n            calculatePrizeDistributionWithDrawData(\\n                _drawId,\\n                _totalNetworkTicketSupply,\\n                draw.beaconPeriodSeconds,\\n                draw.timestamp\\n            );\\n    }\\n\\n    /**\\n     * @notice Calculates what the prize distribution will be, given a draw id and total network ticket supply.\\n     * @param _drawId The draw from which to use the Draw and\\n     * @param _totalNetworkTicketSupply The sum of all ticket supplies across all prize pools on the network\\n     * @param _beaconPeriodSeconds The beacon period in seconds\\n     * @param _drawTimestamp The timestamp at which the draw RNG request started.\\n     * @return A PrizeDistribution based on the given params and PrizeTier for the passed draw id\\n     */\\n    function calculatePrizeDistributionWithDrawData(\\n        uint32 _drawId,\\n        uint256 _totalNetworkTicketSupply,\\n        uint32 _beaconPeriodSeconds,\\n        uint64 _drawTimestamp\\n    ) public view virtual returns (IPrizeDistributionBuffer.PrizeDistribution memory) {\\n        uint256 maxPicks = _totalNetworkTicketSupply / minPickCost;\\n\\n        IPrizeDistributionBuffer.PrizeDistribution\\n            memory prizeDistribution = _calculatePrizeDistribution(\\n                _drawId,\\n                _beaconPeriodSeconds,\\n                maxPicks\\n            );\\n\\n        uint64[] memory startTimestamps = new uint64[](1);\\n        uint64[] memory endTimestamps = new uint64[](1);\\n\\n        startTimestamps[0] = _drawTimestamp - prizeDistribution.startTimestampOffset;\\n        endTimestamps[0] = _drawTimestamp - prizeDistribution.endTimestampOffset;\\n\\n        uint256[] memory ticketAverageTotalSupplies = ticket.getAverageTotalSuppliesBetween(\\n            startTimestamps,\\n            endTimestamps\\n        );\\n\\n        require(\\n            _totalNetworkTicketSupply >= ticketAverageTotalSupplies[0],\\n            \\\"PDF/invalid-network-supply\\\"\\n        );\\n\\n        if (_totalNetworkTicketSupply > 0) {\\n            prizeDistribution.numberOfPicks = uint256(\\n                (prizeDistribution.numberOfPicks * ticketAverageTotalSupplies[0]) /\\n                    _totalNetworkTicketSupply\\n            ).toUint104();\\n        } else {\\n            prizeDistribution.numberOfPicks = 0;\\n        }\\n\\n        return prizeDistribution;\\n    }\\n\\n    /**\\n     * @notice Gets the PrizeDistributionBuffer for a drawId\\n     * @param _drawId drawId\\n     * @param _startTimestampOffset The start timestamp offset to use for the prize distribution\\n     * @param _maxPicks The maximum picks that the distribution should allow.  The Prize Distribution's numberOfPicks will be less than or equal to this number.\\n     * @return prizeDistribution\\n     */\\n    function _calculatePrizeDistribution(\\n        uint32 _drawId,\\n        uint32 _startTimestampOffset,\\n        uint256 _maxPicks\\n    ) internal view virtual returns (IPrizeDistributionBuffer.PrizeDistribution memory) {\\n        IPrizeTierHistory.PrizeTier memory prizeTier = prizeTierHistory.getPrizeTier(_drawId);\\n\\n        uint8 cardinality;\\n        do {\\n            cardinality++;\\n        } while ((2**prizeTier.bitRangeSize)**(cardinality + 1) < _maxPicks);\\n\\n        IPrizeDistributionBuffer.PrizeDistribution\\n            memory prizeDistribution = IPrizeDistributionSource.PrizeDistribution({\\n                bitRangeSize: prizeTier.bitRangeSize,\\n                matchCardinality: cardinality,\\n                startTimestampOffset: _startTimestampOffset,\\n                endTimestampOffset: prizeTier.endTimestampOffset,\\n                maxPicksPerUser: prizeTier.maxPicksPerUser,\\n                expiryDuration: prizeTier.expiryDuration,\\n                numberOfPicks: uint256((2**prizeTier.bitRangeSize)**cardinality).toUint104(),\\n                tiers: prizeTier.tiers,\\n                prize: prizeTier.prize\\n            });\\n\\n        return prizeDistribution;\\n    }\\n}\\n\",\"keccak256\":\"0x912e5b071a950f2e723006b309c937020c8c24b68bbff33b59f5372d68d938cf\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IPrizeTierHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity 0.8.6;\\nimport \\\"@pooltogether/v4-core/contracts/DrawBeacon.sol\\\";\\n\\n/**\\n * @title  PoolTogether V4 IPrizeTierHistory\\n * @author PoolTogether Inc Team\\n * @notice IPrizeTierHistory is the base contract for PrizeTierHistory\\n */\\ninterface IPrizeTierHistory {\\n    /**\\n     * @notice Linked Draw and PrizeDistribution parameters storage schema\\n     */\\n    struct PrizeTier {\\n        uint8 bitRangeSize;\\n        uint32 drawId;\\n        uint32 maxPicksPerUser;\\n        uint32 expiryDuration;\\n        uint32 endTimestampOffset;\\n        uint256 prize;\\n        uint32[16] tiers;\\n    }\\n\\n    /**\\n     * @notice Emit when new PrizeTier is added to history\\n     * @param drawId    Draw ID\\n     * @param prizeTier PrizeTier parameters\\n     */\\n    event PrizeTierPushed(uint32 indexed drawId, PrizeTier prizeTier);\\n\\n    /**\\n     * @notice Emit when existing PrizeTier is updated in history\\n     * @param drawId    Draw ID\\n     * @param prizeTier PrizeTier parameters\\n     */\\n    event PrizeTierSet(uint32 indexed drawId, PrizeTier prizeTier);\\n\\n    /**\\n     * @notice Push PrizeTierHistory struct onto history array.\\n     * @dev    Callable only by owner or manager,\\n     * @param drawPrizeDistribution New PrizeTierHistory struct\\n     */\\n    function push(PrizeTier calldata drawPrizeDistribution) external;\\n\\n    function replace(PrizeTier calldata _prizeTier) external;\\n\\n    /**\\n     * @notice Read PrizeTierHistory struct from history array.\\n     * @param drawId Draw ID\\n     * @return prizeTier\\n     */\\n    function getPrizeTier(uint32 drawId) external view returns (PrizeTier memory prizeTier);\\n\\n    /**\\n     * @notice Read first Draw ID used to initialize history\\n     * @return Draw ID of first PrizeTier record\\n     */\\n    function getOldestDrawId() external view returns (uint32);\\n\\n    function getNewestDrawId() external view returns (uint32);\\n\\n    /**\\n     * @notice Read PrizeTierHistory List from history array.\\n     * @param drawIds Draw ID array\\n     * @return prizeTierList\\n     */\\n    function getPrizeTierList(uint32[] calldata drawIds)\\n        external\\n        view\\n        returns (PrizeTier[] memory prizeTierList);\\n\\n    /**\\n     * @notice Push PrizeTierHistory struct onto history array.\\n     * @dev    Callable only by owner.\\n     * @param prizeTier Updated PrizeTierHistory struct\\n     * @return drawId Draw ID linked to PrizeTierHistory\\n     */\\n    function popAndPush(PrizeTier calldata prizeTier) external returns (uint32 drawId);\\n\\n    function getPrizeTierAtIndex(uint256 index) external view returns (PrizeTier memory);\\n\\n    /**\\n     * @notice Returns the number of Prize Tier structs pushed\\n     * @return The number of prize tiers that have been pushed\\n     */\\n    function count() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xd521322f630dfcb577a28bdbdc0f13a17ef1eb7152d3daa193dd76e1be3d8e7c\",\"license\":\"GPL-3.0\"}},\"version\":1}",
  "bytecode": "0x6101206040523480156200001257600080fd5b5060405162001b5b38038062001b5b833981016040819052620000359162000284565b85620000418162000234565b506001600160a01b0386166200008f5760405162461bcd60e51b815260206004820152600e60248201526d5044432f6f776e65722d7a65726f60901b60448201526064015b60405180910390fd5b6001600160a01b038516620000d65760405162461bcd60e51b815260206004820152600c60248201526b5044432f7074682d7a65726f60a01b604482015260640162000086565b6001600160a01b0384166200011c5760405162461bcd60e51b815260206004820152600b60248201526a5044432f64622d7a65726f60a81b604482015260640162000086565b6001600160a01b038316620001635760405162461bcd60e51b815260206004820152600c60248201526b5044432f7064622d7a65726f60a01b604482015260640162000086565b6001600160a01b038216620001ad5760405162461bcd60e51b815260206004820152600f60248201526e5044432f7469636b65742d7a65726f60881b604482015260640162000086565b60008111620001ff5760405162461bcd60e51b815260206004820152601560248201527f5044432f7069636b2d636f73742d67742d7a65726f0000000000000000000000604482015260640162000086565b610100526001600160601b0319606094851b811660805292841b831660a05290831b821660c05290911b1660e0525062000325565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008060008060008060c087890312156200029e57600080fd5b8651620002ab816200030c565b6020880151909650620002be816200030c565b6040880151909550620002d1816200030c565b6060880151909450620002e4816200030c565b6080880151909350620002f7816200030c565b8092505060a087015190509295509295509295565b6001600160a01b03811681146200032257600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c610100516117bb620003a06000396000818161013301526106ac01526000818161020f01526107de015260008181610168015281816103ca015261054d0152600081816102620152610a0a0152600081816101a70152610cfe01526117bb6000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80636cc25db711610097578063ce343bb611610066578063ce343bb61461025d578063d0ebdbe714610284578063e30c3978146102a7578063f2fde38b146102b857600080fd5b80636cc25db71461020a578063715018a6146102315780638bf02df8146102395780638da5cb5b1461024c57600080fd5b80633ec018fc116100d35780633ec018fc146101c9578063481c6a75146101dc5780634e71e0c8146101ed5780636665f32b146101f757600080fd5b80630348b07614610105578063082d80ff1461012e5780630840bbdd146101635780633cd4b918146101a2575b600080fd5b61011861011336600461131f565b6102cb565b60405161012591906114f7565b60405180910390f35b6101557f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610125565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610125565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6101186101d736600461131f565b61049d565b6002546001600160a01b031661018a565b6101f561060f565b005b61011861020536600461134b565b61069d565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6101f5610956565b61011861024736600461131f565b6109cb565b6000546001600160a01b031661018a565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6102976102923660046110e6565b610aaa565b6040519015158152602001610125565b6001546001600160a01b031661018a565b6101f56102c63660046110e6565b610b26565b6102d3610fe6565b336102e66002546001600160a01b031690565b6001600160a01b031614806103145750336103096000546001600160a01b031690565b6001600160a01b0316145b61038b5760405162461bcd60e51b815260206004820152602660248201527f4d616e61676561626c652f63616c6c65722d6e6f742d6d616e616765722d6f7260448201527f2d6f776e6572000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600061039784846109cb565b6040517f1124e1dc0000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631124e1dc906104019087908590600401611506565b602060405180830381600087803b15801561041b57600080fd5b505af115801561042f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045391906111bc565b508363ffffffff167f362b45fbcdb636bf7950cef7aeb4d38e93501268c3627eb4fd7c68d1550eaea98460405161048c91815260200190565b60405180910390a290505b92915050565b6104a5610fe6565b336104b86000546001600160a01b031690565b6001600160a01b03161461050e5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b600061051a84846109cb565b6040517fce336ce90000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ce336ce9906105849087908590600401611506565b602060405180830381600087803b15801561059e57600080fd5b505af11580156105b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d69190611302565b508363ffffffff167f62230ad64212d08d65551ffdab2c5eb6be8c31bea5d493cac0a51a65f84758e98460405161048c91815260200190565b6001546001600160a01b031633146106695760405162461bcd60e51b815260206004820152601f60248201527f4f776e61626c652f63616c6c65722d6e6f742d70656e64696e674f776e6572006044820152606401610382565b60015461067e906001600160a01b0316610c62565b6001805473ffffffffffffffffffffffffffffffffffffffff19169055565b6106a5610fe6565b60006106d17f0000000000000000000000000000000000000000000000000000000000000000866115a0565b905060006106e0878684610cbf565b60408051600180825281830190925291925060009190602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337505050604084015190915061073e9063ffffffff16876116cf565b826000815181106107515761075161172e565b67ffffffffffffffff90921660209283029190910190910152606083015161077f9063ffffffff16876116cf565b816000815181106107925761079261172e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a9061081590869086906004016114c9565b60006040518083038186803b15801561082d57600080fd5b505afa158015610841573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610869919081019061110f565b90508060008151811061087e5761087e61172e565b60200260200101518910156108d55760405162461bcd60e51b815260206004820152601a60248201527f5044462f696e76616c69642d6e6574776f726b2d737570706c790000000000006044820152606401610382565b88156109405761092789826000815181106108f2576108f261172e565b60200260200101518660c001516cffffffffffffffffffffffffff1661091891906116b0565b61092291906115a0565b610e71565b6cffffffffffffffffffffffffff1660c0850152610948565b600060c08501525b509198975050505050505050565b336109696000546001600160a01b031690565b6001600160a01b0316146109bf5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b6109c96000610c62565b565b6109d3610fe6565b6040517f83c34aaf00000000000000000000000000000000000000000000000000000000815263ffffffff841660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906383c34aaf9060240160a06040518083038186803b158015610a5457600080fd5b505afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c91906111de565b9050610aa284848360800151846040015161069d565b949350505050565b600033610abf6000546001600160a01b031690565b6001600160a01b031614610b155760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b610b1e82610efa565b90505b919050565b33610b396000546001600160a01b031690565b6001600160a01b031614610b8f5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b6001600160a01b038116610c0b5760405162461bcd60e51b815260206004820152602560248201527f4f776e61626c652f70656e64696e674f776e65722d6e6f742d7a65726f2d616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610382565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f239a2ddded15777fa246aed5f7e1a9bc69a39d4eb4a397034d1d85766cca7d4c90600090a250565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610cc7610fe6565b6040517f4aac253d00000000000000000000000000000000000000000000000000000000815263ffffffff851660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690634aac253d906024016102c06040518083038186803b158015610d4957600080fd5b505afa158015610d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d81919061126d565b905060005b80610d90816116f8565b9150849050610da082600161157b565b8351610dad906002611605565b610db79190611605565b10610d86576000604051806101200160405280846000015160ff1681526020018360ff1681526020018763ffffffff168152602001846080015163ffffffff168152602001846040015163ffffffff168152602001846060015163ffffffff168152602001610e3b8486600001516002610e319190611605565b6109229190611605565b6cffffffffffffffffffffffffff1681526020018460c0015181526020018460a0015181525090508093505050505b9392505050565b60006cffffffffffffffffffffffffff821115610ef65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f30342062697473000000000000000000000000000000000000000000000000006064820152608401610382565b5090565b6002546000906001600160a01b03908116908316811415610f835760405162461bcd60e51b815260206004820152602360248201527f4d616e61676561626c652f6578697374696e672d6d616e616765722d6164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610382565b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0385811691821790925560405190918316907f9cb45c728de594dab506a1f1a8554e24c8eeaf983618d5ec5dd7bc6f3c49feee90600090a350600192915050565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915260e0810161102c611039565b8152602001600081525090565b6040518061020001604052806010906020820280368337509192915050565b600082601f83011261106957600080fd5b60405161020080820182811067ffffffffffffffff8211171561108e5761108e611744565b60405281848281018710156110a257600080fd5b600092505b60108310156110d05780516110bb8161175a565b825260019290920191602091820191016110a7565b509195945050505050565b8051610b218161175a565b6000602082840312156110f857600080fd5b81356001600160a01b0381168114610e6a57600080fd5b6000602080838503121561112257600080fd5b825167ffffffffffffffff8082111561113a57600080fd5b818501915085601f83011261114e57600080fd5b81518181111561116057611160611744565b8060051b915061117184830161154a565b8181528481019084860184860187018a101561118c57600080fd5b600095505b838610156111af578051835260019590950194918601918601611191565b5098975050505050505050565b6000602082840312156111ce57600080fd5b81518015158114610e6a57600080fd5b600060a082840312156111f057600080fd5b60405160a0810181811067ffffffffffffffff8211171561121357611213611744565b6040528251815260208301516112288161175a565b6020820152604083015161123b8161176f565b6040820152606083015161124e8161176f565b606082015260808301516112618161175a565b60808201529392505050565b60006102c0828403121561128057600080fd5b611288611521565b825160ff8116811461129957600080fd5b81526112a7602084016110db565b60208201526112b8604084016110db565b60408201526112c9606084016110db565b60608201526112da608084016110db565b608082015260a083015160a08201526112f68460c08501611058565b60c08201529392505050565b60006020828403121561131457600080fd5b8151610e6a8161175a565b6000806040838503121561133257600080fd5b823561133d8161175a565b946020939093013593505050565b6000806000806080858703121561136157600080fd5b843561136c8161175a565b93506020850135925060408501356113838161175a565b915060608501356113938161176f565b939692955090935050565b8060005b60108110156113c757815163ffffffff168452602093840193909101906001016113a2565b50505050565b600081518084526020808501945080840160005b8381101561140757815167ffffffffffffffff16875295820195908201906001016113e1565b509495945050505050565b60ff815116825260ff6020820151166020830152604081015161143d604084018263ffffffff169052565b506060810151611455606084018263ffffffff169052565b50608081015161146d608084018263ffffffff169052565b5060a081015161148560a084018263ffffffff169052565b5060c08101516114a660c08401826cffffffffffffffffffffffffff169052565b5060e08101516114b960e084018261139e565b5061010001516102e09190910152565b6040815260006114dc60408301856113cd565b82810360208401526114ee81856113cd565b95945050505050565b61030081016104978284611412565b63ffffffff831681526103208101610e6a6020830184611412565b60405160e0810167ffffffffffffffff8111828210171561154457611544611744565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561157357611573611744565b604052919050565b600060ff821660ff84168060ff0382111561159857611598611718565b019392505050565b6000826115bd57634e487b7160e01b600052601260045260246000fd5b500490565b600181815b808511156115fd5781600019048211156115e3576115e3611718565b808516156115f057918102915b93841c93908002906115c7565b509250929050565b6000610e6a60ff84168360008261161e57506001610497565b8161162b57506000610497565b8160018114611641576002811461164b57611667565b6001915050610497565b60ff84111561165c5761165c611718565b50506001821b610497565b5060208310610133831016604e8410600b841016171561168a575081810a610497565b61169483836115c2565b80600019048211156116a8576116a8611718565b029392505050565b60008160001904831182151516156116ca576116ca611718565b500290565b600067ffffffffffffffff838116908316818110156116f0576116f0611718565b039392505050565b600060ff821660ff81141561170f5761170f611718565b60010192915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b63ffffffff8116811461176c57600080fd5b50565b67ffffffffffffffff8116811461176c57600080fdfea26469706673582212200dd0da451f2c59a7bc8142630a7d05509c815573493d2be1c3fa5f8752c27eab64736f6c63430008060033",
  "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101005760003560e01c80636cc25db711610097578063ce343bb611610066578063ce343bb61461025d578063d0ebdbe714610284578063e30c3978146102a7578063f2fde38b146102b857600080fd5b80636cc25db71461020a578063715018a6146102315780638bf02df8146102395780638da5cb5b1461024c57600080fd5b80633ec018fc116100d35780633ec018fc146101c9578063481c6a75146101dc5780634e71e0c8146101ed5780636665f32b146101f757600080fd5b80630348b07614610105578063082d80ff1461012e5780630840bbdd146101635780633cd4b918146101a2575b600080fd5b61011861011336600461131f565b6102cb565b60405161012591906114f7565b60405180910390f35b6101557f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610125565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610125565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6101186101d736600461131f565b61049d565b6002546001600160a01b031661018a565b6101f561060f565b005b61011861020536600461134b565b61069d565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6101f5610956565b61011861024736600461131f565b6109cb565b6000546001600160a01b031661018a565b61018a7f000000000000000000000000000000000000000000000000000000000000000081565b6102976102923660046110e6565b610aaa565b6040519015158152602001610125565b6001546001600160a01b031661018a565b6101f56102c63660046110e6565b610b26565b6102d3610fe6565b336102e66002546001600160a01b031690565b6001600160a01b031614806103145750336103096000546001600160a01b031690565b6001600160a01b0316145b61038b5760405162461bcd60e51b815260206004820152602660248201527f4d616e61676561626c652f63616c6c65722d6e6f742d6d616e616765722d6f7260448201527f2d6f776e6572000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600061039784846109cb565b6040517f1124e1dc0000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631124e1dc906104019087908590600401611506565b602060405180830381600087803b15801561041b57600080fd5b505af115801561042f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045391906111bc565b508363ffffffff167f362b45fbcdb636bf7950cef7aeb4d38e93501268c3627eb4fd7c68d1550eaea98460405161048c91815260200190565b60405180910390a290505b92915050565b6104a5610fe6565b336104b86000546001600160a01b031690565b6001600160a01b03161461050e5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b600061051a84846109cb565b6040517fce336ce90000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ce336ce9906105849087908590600401611506565b602060405180830381600087803b15801561059e57600080fd5b505af11580156105b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d69190611302565b508363ffffffff167f62230ad64212d08d65551ffdab2c5eb6be8c31bea5d493cac0a51a65f84758e98460405161048c91815260200190565b6001546001600160a01b031633146106695760405162461bcd60e51b815260206004820152601f60248201527f4f776e61626c652f63616c6c65722d6e6f742d70656e64696e674f776e6572006044820152606401610382565b60015461067e906001600160a01b0316610c62565b6001805473ffffffffffffffffffffffffffffffffffffffff19169055565b6106a5610fe6565b60006106d17f0000000000000000000000000000000000000000000000000000000000000000866115a0565b905060006106e0878684610cbf565b60408051600180825281830190925291925060009190602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337505050604084015190915061073e9063ffffffff16876116cf565b826000815181106107515761075161172e565b67ffffffffffffffff90921660209283029190910190910152606083015161077f9063ffffffff16876116cf565b816000815181106107925761079261172e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a9061081590869086906004016114c9565b60006040518083038186803b15801561082d57600080fd5b505afa158015610841573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610869919081019061110f565b90508060008151811061087e5761087e61172e565b60200260200101518910156108d55760405162461bcd60e51b815260206004820152601a60248201527f5044462f696e76616c69642d6e6574776f726b2d737570706c790000000000006044820152606401610382565b88156109405761092789826000815181106108f2576108f261172e565b60200260200101518660c001516cffffffffffffffffffffffffff1661091891906116b0565b61092291906115a0565b610e71565b6cffffffffffffffffffffffffff1660c0850152610948565b600060c08501525b509198975050505050505050565b336109696000546001600160a01b031690565b6001600160a01b0316146109bf5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b6109c96000610c62565b565b6109d3610fe6565b6040517f83c34aaf00000000000000000000000000000000000000000000000000000000815263ffffffff841660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906383c34aaf9060240160a06040518083038186803b158015610a5457600080fd5b505afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c91906111de565b9050610aa284848360800151846040015161069d565b949350505050565b600033610abf6000546001600160a01b031690565b6001600160a01b031614610b155760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b610b1e82610efa565b90505b919050565b33610b396000546001600160a01b031690565b6001600160a01b031614610b8f5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e657200000000000000006044820152606401610382565b6001600160a01b038116610c0b5760405162461bcd60e51b815260206004820152602560248201527f4f776e61626c652f70656e64696e674f776e65722d6e6f742d7a65726f2d616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610382565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f239a2ddded15777fa246aed5f7e1a9bc69a39d4eb4a397034d1d85766cca7d4c90600090a250565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610cc7610fe6565b6040517f4aac253d00000000000000000000000000000000000000000000000000000000815263ffffffff851660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690634aac253d906024016102c06040518083038186803b158015610d4957600080fd5b505afa158015610d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d81919061126d565b905060005b80610d90816116f8565b9150849050610da082600161157b565b8351610dad906002611605565b610db79190611605565b10610d86576000604051806101200160405280846000015160ff1681526020018360ff1681526020018763ffffffff168152602001846080015163ffffffff168152602001846040015163ffffffff168152602001846060015163ffffffff168152602001610e3b8486600001516002610e319190611605565b6109229190611605565b6cffffffffffffffffffffffffff1681526020018460c0015181526020018460a0015181525090508093505050505b9392505050565b60006cffffffffffffffffffffffffff821115610ef65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f30342062697473000000000000000000000000000000000000000000000000006064820152608401610382565b5090565b6002546000906001600160a01b03908116908316811415610f835760405162461bcd60e51b815260206004820152602360248201527f4d616e61676561626c652f6578697374696e672d6d616e616765722d6164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610382565b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0385811691821790925560405190918316907f9cb45c728de594dab506a1f1a8554e24c8eeaf983618d5ec5dd7bc6f3c49feee90600090a350600192915050565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915260e0810161102c611039565b8152602001600081525090565b6040518061020001604052806010906020820280368337509192915050565b600082601f83011261106957600080fd5b60405161020080820182811067ffffffffffffffff8211171561108e5761108e611744565b60405281848281018710156110a257600080fd5b600092505b60108310156110d05780516110bb8161175a565b825260019290920191602091820191016110a7565b509195945050505050565b8051610b218161175a565b6000602082840312156110f857600080fd5b81356001600160a01b0381168114610e6a57600080fd5b6000602080838503121561112257600080fd5b825167ffffffffffffffff8082111561113a57600080fd5b818501915085601f83011261114e57600080fd5b81518181111561116057611160611744565b8060051b915061117184830161154a565b8181528481019084860184860187018a101561118c57600080fd5b600095505b838610156111af578051835260019590950194918601918601611191565b5098975050505050505050565b6000602082840312156111ce57600080fd5b81518015158114610e6a57600080fd5b600060a082840312156111f057600080fd5b60405160a0810181811067ffffffffffffffff8211171561121357611213611744565b6040528251815260208301516112288161175a565b6020820152604083015161123b8161176f565b6040820152606083015161124e8161176f565b606082015260808301516112618161175a565b60808201529392505050565b60006102c0828403121561128057600080fd5b611288611521565b825160ff8116811461129957600080fd5b81526112a7602084016110db565b60208201526112b8604084016110db565b60408201526112c9606084016110db565b60608201526112da608084016110db565b608082015260a083015160a08201526112f68460c08501611058565b60c08201529392505050565b60006020828403121561131457600080fd5b8151610e6a8161175a565b6000806040838503121561133257600080fd5b823561133d8161175a565b946020939093013593505050565b6000806000806080858703121561136157600080fd5b843561136c8161175a565b93506020850135925060408501356113838161175a565b915060608501356113938161176f565b939692955090935050565b8060005b60108110156113c757815163ffffffff168452602093840193909101906001016113a2565b50505050565b600081518084526020808501945080840160005b8381101561140757815167ffffffffffffffff16875295820195908201906001016113e1565b509495945050505050565b60ff815116825260ff6020820151166020830152604081015161143d604084018263ffffffff169052565b506060810151611455606084018263ffffffff169052565b50608081015161146d608084018263ffffffff169052565b5060a081015161148560a084018263ffffffff169052565b5060c08101516114a660c08401826cffffffffffffffffffffffffff169052565b5060e08101516114b960e084018261139e565b5061010001516102e09190910152565b6040815260006114dc60408301856113cd565b82810360208401526114ee81856113cd565b95945050505050565b61030081016104978284611412565b63ffffffff831681526103208101610e6a6020830184611412565b60405160e0810167ffffffffffffffff8111828210171561154457611544611744565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561157357611573611744565b604052919050565b600060ff821660ff84168060ff0382111561159857611598611718565b019392505050565b6000826115bd57634e487b7160e01b600052601260045260246000fd5b500490565b600181815b808511156115fd5781600019048211156115e3576115e3611718565b808516156115f057918102915b93841c93908002906115c7565b509250929050565b6000610e6a60ff84168360008261161e57506001610497565b8161162b57506000610497565b8160018114611641576002811461164b57611667565b6001915050610497565b60ff84111561165c5761165c611718565b50506001821b610497565b5060208310610133831016604e8410600b841016171561168a575081810a610497565b61169483836115c2565b80600019048211156116a8576116a8611718565b029392505050565b60008160001904831182151516156116ca576116ca611718565b500290565b600067ffffffffffffffff838116908316818110156116f0576116f0611718565b039392505050565b600060ff821660ff81141561170f5761170f611718565b60010192915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b63ffffffff8116811461176c57600080fd5b50565b67ffffffffffffffff8116811461176c57600080fdfea26469706673582212200dd0da451f2c59a7bc8142630a7d05509c815573493d2be1c3fa5f8752c27eab64736f6c63430008060033",
  "devdoc": {
    "author": "PoolTogether Inc.",
    "events": {
      "PrizeDistributionPushed(uint32,uint256)": {
        "params": {
          "drawId": "The draw id for which the prize dist was pushed",
          "totalNetworkTicketSupply": "The total network ticket supply that was used to compute the cardinality and portion of picks"
        }
      },
      "PrizeDistributionSet(uint32,uint256)": {
        "params": {
          "drawId": "The draw id for which the prize dist was set",
          "totalNetworkTicketSupply": "The total network ticket supply that was used to compute the cardinality and portion of picks"
        }
      }
    },
    "kind": "dev",
    "methods": {
      "calculatePrizeDistribution(uint32,uint256)": {
        "params": {
          "_drawId": "The draw id to pull from the Draw Buffer and Prize Tier History",
          "_totalNetworkTicketSupply": "The total of all ticket supplies across all prize pools in this network"
        },
        "returns": {
          "_0": "PrizeDistribution using info from the Draw for the given draw id, total network ticket supply, and PrizeTier for the draw."
        }
      },
      "calculatePrizeDistributionWithDrawData(uint32,uint256,uint32,uint64)": {
        "params": {
          "_beaconPeriodSeconds": "The beacon period in seconds",
          "_drawId": "The draw from which to use the Draw and",
          "_drawTimestamp": "The timestamp at which the draw RNG request started.",
          "_totalNetworkTicketSupply": "The sum of all ticket supplies across all prize pools on the network"
        },
        "returns": {
          "_0": "A PrizeDistribution based on the given params and PrizeTier for the passed draw id"
        }
      },
      "claimOwnership()": {
        "details": "This function is only callable by the `_pendingOwner`."
      },
      "manager()": {
        "returns": {
          "_0": "Current `_manager` address."
        }
      },
      "pendingOwner()": {
        "returns": {
          "_0": "Current `_pendingOwner` address."
        }
      },
      "pushPrizeDistribution(uint32,uint256)": {
        "params": {
          "_drawId": "The draw id to compute for",
          "_totalNetworkTicketSupply": "The total supply of tickets across all prize pools for the network that the ticket belongs to."
        },
        "returns": {
          "_0": "The resulting Prize Distribution"
        }
      },
      "renounceOwnership()": {
        "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner."
      },
      "setManager(address)": {
        "details": "Throws if called by any account other than the owner.",
        "params": {
          "_newManager": "New _manager address."
        },
        "returns": {
          "_0": "Boolean to indicate if the operation was successful or not."
        }
      },
      "setPrizeDistribution(uint32,uint256)": {
        "params": {
          "_drawId": "The draw id to compute for",
          "_totalNetworkTicketSupply": "The total supply of tickets across all prize pools for the network that the ticket belongs to."
        },
        "returns": {
          "_0": "The resulting Prize Distribution"
        }
      },
      "transferOwnership(address)": {
        "params": {
          "_newOwner": "Address to transfer ownership to."
        }
      }
    },
    "title": "Prize Distribution Factory",
    "version": 1
  },
  "userdoc": {
    "events": {
      "PrizeDistributionPushed(uint32,uint256)": {
        "notice": "Emitted when a new Prize Distribution is pushed."
      },
      "PrizeDistributionSet(uint32,uint256)": {
        "notice": "Emitted when a Prize Distribution is set (overrides another)"
      }
    },
    "kind": "user",
    "methods": {
      "calculatePrizeDistribution(uint32,uint256)": {
        "notice": "Calculates what the prize distribution will be, given a draw id and total network ticket supply."
      },
      "calculatePrizeDistributionWithDrawData(uint32,uint256,uint32,uint64)": {
        "notice": "Calculates what the prize distribution will be, given a draw id and total network ticket supply."
      },
      "claimOwnership()": {
        "notice": "Allows the `_pendingOwner` address to finalize the transfer."
      },
      "drawBuffer()": {
        "notice": "The draw buffer to pull the draw from"
      },
      "manager()": {
        "notice": "Gets current `_manager`."
      },
      "minPickCost()": {
        "notice": "The minimum cost of each pick.  Used to calculate the cardinality."
      },
      "owner()": {
        "notice": "Returns the address of the current owner."
      },
      "pendingOwner()": {
        "notice": "Gets current `_pendingOwner`."
      },
      "prizeDistributionBuffer()": {
        "notice": "The prize distribution buffer to push and set.  This contract must be the manager or owner of the buffer."
      },
      "prizeTierHistory()": {
        "notice": "The prize tier history to pull tier information from"
      },
      "pushPrizeDistribution(uint32,uint256)": {
        "notice": "Allows the owner or manager to push a new prize distribution onto the buffer. The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality."
      },
      "renounceOwnership()": {
        "notice": "Renounce ownership of the contract."
      },
      "setManager(address)": {
        "notice": "Set or change of manager."
      },
      "setPrizeDistribution(uint32,uint256)": {
        "notice": "Allows the owner or manager to override an existing prize distribution in the buffer. The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality."
      },
      "ticket()": {
        "notice": "The ticket whose average total supply will be measured to calculate the portion of picks"
      },
      "transferOwnership(address)": {
        "notice": "Allows current owner to set the `_pendingOwner` address."
      }
    },
    "notice": "The Prize Distribution Factory populates a Prize Distribution Buffer for a prize pool.  It uses a Prize Tier History, Draw Buffer and Ticket to compute the correct prize distribution.  It automatically sets the cardinality based on the minPickCost and the total network ticket supply.",
    "version": 1
  },
  "storageLayout": {
    "storage": [
      {
        "astId": 3108,
        "contract": "contracts/PrizeDistributionFactory.sol:PrizeDistributionFactory",
        "label": "_owner",
        "offset": 0,
        "slot": "0",
        "type": "t_address"
      },
      {
        "astId": 3110,
        "contract": "contracts/PrizeDistributionFactory.sol:PrizeDistributionFactory",
        "label": "_pendingOwner",
        "offset": 0,
        "slot": "1",
        "type": "t_address"
      },
      {
        "astId": 3006,
        "contract": "contracts/PrizeDistributionFactory.sol:PrizeDistributionFactory",
        "label": "_manager",
        "offset": 0,
        "slot": "2",
        "type": "t_address"
      }
    ],
    "types": {
      "t_address": {
        "encoding": "inplace",
        "label": "address",
        "numberOfBytes": "20"
      }
    }
  }
}