From 2fb5f2770b0a725cb950ea2a0c269c485f8d3495 Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Thu, 2 Jun 2022 11:58:36 -0500 Subject: [PATCH 1/7] chore(package): bump v4-periphery --- hardhat.config.dependencies.ts | 8 +++----- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/hardhat.config.dependencies.ts b/hardhat.config.dependencies.ts index 8fb7cf9..78ffe81 100644 --- a/hardhat.config.dependencies.ts +++ b/hardhat.config.dependencies.ts @@ -6,6 +6,9 @@ export const external = { { artifacts: 'node_modules/@pooltogether/yield-source-interface/artifacts', }, + { + artifacts: 'node_modules/@pooltogether/v4-periphery/artifacts', + }, ], deployments: { mainnet: ['node_modules/@pooltogether/pooltogether-rng-contracts/deployments/mainnet'], @@ -34,11 +37,6 @@ export const dependencyCompiler = { '@pooltogether/v4-timelocks/contracts/DrawCalculatorTimelock.sol', '@pooltogether/v4-timelocks/contracts/BeaconTimelockTrigger.sol', '@pooltogether/v4-timelocks/contracts/ReceiverTimelockTrigger.sol', - // Periphery - '@pooltogether/v4-periphery/contracts/PrizeFlush.sol', - '@pooltogether/v4-periphery/contracts/PrizeTierHistory.sol', - '@pooltogether/v4-periphery/contracts/PrizeDistributionFactory.sol', - '@pooltogether/v4-periphery/contracts/TwabRewards.sol', // TWAB Delegator '@pooltogether/v4-twab-delegator/contracts/TWABDelegator.sol', // YieldSource diff --git a/package.json b/package.json index cca60f7..e5f6096 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@pooltogether/owner-manager-contracts": "1.1.0", "@pooltogether/pooltogether-rng-contracts": "1.5.1", "@pooltogether/v4-core": "1.3.0-beta.1", - "@pooltogether/v4-periphery": "1.2.2", + "@pooltogether/v4-periphery": "1.2.5", "@pooltogether/v4-timelocks": "1.1.0", "@pooltogether/v4-twab-delegator": "1.0.0", "@pooltogether/yield-source-interface": "1.3.0", diff --git a/yarn.lock b/yarn.lock index 6cf3652..6e3e4b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1054,10 +1054,10 @@ "@pooltogether/yield-source-interface" "1.3.0" deploy-eip-1820 "1.0.0" -"@pooltogether/v4-periphery@1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@pooltogether/v4-periphery/-/v4-periphery-1.2.2.tgz#400f9acb642ebd2fa0a1acc9fed6a91041383e54" - integrity sha512-bzYr/v3e0Qudb3TDltTJdTkcd9/67CAwOQZwQwMa3/Jgcx0oRthpgTkyeGh2CnJyahIgbNpg7JPP/FlsAkiRkQ== +"@pooltogether/v4-periphery@1.2.5": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@pooltogether/v4-periphery/-/v4-periphery-1.2.5.tgz#12125fc8f1b6a8efaa9bfb4855a7a0c63b16ee35" + integrity sha512-Q9E+o3cNh+w7HJLTp/lGJ0/DmfBQyCEyIwnD+uw6AZfaP9dykDFOkbTsHw6QYjS5+uUbklMjtSb5KSwPAuA9dA== "@pooltogether/v4-timelocks@1.1.0": version "1.1.0" From 20d02732085316119926542e5dc92df9f1d06d3c Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 16:49:48 -0500 Subject: [PATCH 2/7] chore(package): bump hardhat-deploy-markdown-export --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e5f6096..32855ed 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@ethersproject/hardware-wallets": "5.6.0", "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers", "@nomiclabs/hardhat-etherscan": "3.0.0", - "@pooltogether/hardhat-deploy-markdown-export": "0.2.1", + "@pooltogether/hardhat-deploy-markdown-export": "0.3.1", "@types/jsonfile": "6.0.1", "@types/node": "17.0.12", "ajv": "8.9.0", diff --git a/yarn.lock b/yarn.lock index 6e3e4b9..68d492c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1008,10 +1008,10 @@ resolved "https://registry.yarnpkg.com/@pooltogether/fixed-point/-/fixed-point-1.0.0.tgz#2c9fb9fe1cca557ca2be7b9ed7414d5edd5a816f" integrity sha512-YhvjswZuDpKK/NFboyeFWoXhq4763kbi/hNx0L5+6kCRUq8WruvXR4WFvWlDo+5Dx1UsaOnPygAMfrJT0h7bMw== -"@pooltogether/hardhat-deploy-markdown-export@0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@pooltogether/hardhat-deploy-markdown-export/-/hardhat-deploy-markdown-export-0.2.1.tgz#cda48c4e85d1be1e1b69455511dcf150435249c9" - integrity sha512-WKMQWtybHlRKsV3YIKDWBvvdR9d32Wp+DiEtIhzDAhnAD8NGfQptJcC9mgsqwLXg/h1isLiE+yr19ZNckSOYdw== +"@pooltogether/hardhat-deploy-markdown-export@0.3.1": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@pooltogether/hardhat-deploy-markdown-export/-/hardhat-deploy-markdown-export-0.3.1.tgz#f5cb0ee5ec0273ac22b650f73ff6c971f72d0c45" + integrity sha512-1r2WK0tnMlkfPjnvqdDxcEwe8jR78HwsAdCtR7BtEZclKV9P/KfpS/r032t1tK5Nud3nz03puhluot9zUKhjAw== "@pooltogether/owner-manager-contracts@1.1.0": version "1.1.0" From 1e48dbb2ded13aa3e309985848b824f896128208 Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 17:01:48 -0500 Subject: [PATCH 3/7] fix(deployments): redeploy TwabRewards on Polygon --- deployments/polygon/TwabRewards.json | 94 +++---- .../45c8f80dfd4edb590489bcbaf8232d24.json | 255 ++++++++++++++++++ 2 files changed, 302 insertions(+), 47 deletions(-) create mode 100644 deployments/polygon/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json diff --git a/deployments/polygon/TwabRewards.json b/deployments/polygon/TwabRewards.json index 772d33f..8ba7432 100644 --- a/deployments/polygon/TwabRewards.json +++ b/deployments/polygon/TwabRewards.json @@ -1,5 +1,5 @@ { - "address": "0xCa9adB15E33948199066f772C3cb02B62356d764", + "address": "0x1470c87e2db5247A36C60DE3D65D7C972C62EA0f", "abi": [ { "inputs": [ @@ -426,35 +426,35 @@ "type": "function" } ], - "transactionHash": "0xeac59dd8004f912f926d517da90359fc72461a272c7a5a61123124846013ab74", + "transactionHash": "0x96534682eda2a0c0ab557feaea2d693c6d1243c70d0e8e7b6d6f3bf278014f35", "receipt": { "to": null, "from": "0x4D40eb12430A57965cEe3015348d490C6156dF20", - "contractAddress": "0xCa9adB15E33948199066f772C3cb02B62356d764", - "transactionIndex": 40, - "gasUsed": "1759010", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000040000000008000000000000000000000000000000000000000000000000000000000800000000000400000000100000000000000000000000000000000000000000000000000000000000080000000000000000000000000000002000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001100000", - "blockHash": "0x7c47431ac3d7db6a3bf3613c8495b164cbf7868c6df7998b11dff20da4f702e6", - "transactionHash": "0xeac59dd8004f912f926d517da90359fc72461a272c7a5a61123124846013ab74", + "contractAddress": "0x1470c87e2db5247A36C60DE3D65D7C972C62EA0f", + "transactionIndex": 31, + "gasUsed": "1777571", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000008000000000000000000000000000000000000000000020000000000000800000000000000000000100000000000000000000000000000000000000000000000000000000000080000008000004000000000000000002000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001100000", + "blockHash": "0xbe5b3a753a8722949f5a5c5e7a89012d26803ac10d4b51f3b187908aea5ea0ff", + "transactionHash": "0x96534682eda2a0c0ab557feaea2d693c6d1243c70d0e8e7b6d6f3bf278014f35", "logs": [ { - "transactionIndex": 40, - "blockNumber": 24673959, - "transactionHash": "0xeac59dd8004f912f926d517da90359fc72461a272c7a5a61123124846013ab74", + "transactionIndex": 31, + "blockNumber": 29130374, + "transactionHash": "0x96534682eda2a0c0ab557feaea2d693c6d1243c70d0e8e7b6d6f3bf278014f35", "address": "0x0000000000000000000000000000000000001010", "topics": [ "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", "0x0000000000000000000000004d40eb12430a57965cee3015348d490c6156df20", - "0x0000000000000000000000007c7379531b2aee82e4ca06d4175d13b9cbeafd49" + "0x000000000000000000000000b2dd091ea6e591d62f565d7a18ce2a7640add227" ], - "data": "0x00000000000000000000000000000000000000000000000000c1ba1e56d3110200000000000000000000000000000000000000000000000029604f0e34560d1f00000000000000000000000000000000000000000000a299380e52251f04449b000000000000000000000000000000000000000000000000289e94efdd82fc1d00000000000000000000000000000000000000000000a29938d00c4375d7559d", - "logIndex": 162, - "blockHash": "0x7c47431ac3d7db6a3bf3613c8495b164cbf7868c6df7998b11dff20da4f702e6" + "data": "0x000000000000000000000000000000000000000000000000019bb212b4ef882d000000000000000000000000000000000000000000000000249eb8e4c6e340040000000000000000000000000000000000000000000001103c1d28f46e1052b8000000000000000000000000000000000000000000000000230306d211f3b7d70000000000000000000000000000000000000000000001103db8db0722ffdae5", + "logIndex": 306, + "blockHash": "0xbe5b3a753a8722949f5a5c5e7a89012d26803ac10d4b51f3b187908aea5ea0ff" } ], - "blockNumber": 24673959, - "cumulativeGasUsed": "9405155", + "blockNumber": 29130374, + "cumulativeGasUsed": "10089242", "status": 1, "byzantium": true }, @@ -462,10 +462,10 @@ "0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076" ], "numDeployments": 1, - "solcInputHash": "9d2b1510a7a05cdcf74c28c8c70bacde", - "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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 bufffer) 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 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 six month minimum,\\n of historical accurate lookups with current estimates of 1 new block\\n every 15 seconds - the of course contain 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\":\"0xa9cd1103707325d2eaba038d7c0f2b271d934448b8782b82f922653eccb8c90a\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], uint8(index))) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x3700cb7657174461ff5b496bbb3aa481275b6aa692dd62f33e726f1255d39d0b\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611eb56200026e600039600081816101820152818161121a01526113720152611eb56000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", + "solcInputHash": "45c8f80dfd4edb590489bcbaf8232d24", + "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\\n\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x19cf7e6f5b339bb8e553268b1dbafd3e12a00239bc642be87dc363d4832542a8\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002179380380620021798339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611f0b6200026e600039600081816101820152818161127001526113c80152611f0b6000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", "devdoc": { "author": "PoolTogether Inc Team", "details": "This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.", @@ -676,24 +676,24 @@ "storageLayout": { "storage": [ { - "astId": 15925, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12394, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_promotions", "offset": 0, "slot": "0", - "type": "t_mapping(t_uint256,t_struct(Promotion)17216_storage)" + "type": "t_mapping(t_uint256,t_struct(Promotion)13793_storage)" }, { - "astId": 15928, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12397, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_latestPromotionId", "offset": 0, "slot": "1", "type": "t_uint256" }, { - "astId": 15935, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12404, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_claimedEpochs", "offset": 0, "slot": "2", @@ -725,76 +725,76 @@ "numberOfBytes": "32", "value": "t_mapping(t_address,t_uint256)" }, - "t_mapping(t_uint256,t_struct(Promotion)17216_storage)": { + "t_mapping(t_uint256,t_struct(Promotion)13793_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct ITwabRewards.Promotion)", "numberOfBytes": "32", - "value": "t_struct(Promotion)17216_storage" + "value": "t_struct(Promotion)13793_storage" }, - "t_struct(Promotion)17216_storage": { + "t_struct(Promotion)13793_storage": { "encoding": "inplace", "label": "struct ITwabRewards.Promotion", "members": [ { - "astId": 17200, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13777, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "creator", "offset": 0, "slot": "0", "type": "t_address" }, { - "astId": 17202, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13779, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "startTimestamp", "offset": 20, "slot": "0", "type": "t_uint64" }, { - "astId": 17204, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13781, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "numberOfEpochs", "offset": 28, "slot": "0", "type": "t_uint8" }, { - "astId": 17206, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13783, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "epochDuration", "offset": 0, "slot": "1", "type": "t_uint48" }, { - "astId": 17208, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13785, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "createdAt", "offset": 6, "slot": "1", "type": "t_uint48" }, { - "astId": 17211, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13788, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "token", "offset": 12, "slot": "1", "type": "t_contract(IERC20)663" }, { - "astId": 17213, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13790, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "tokensPerEpoch", "offset": 0, "slot": "2", "type": "t_uint256" }, { - "astId": 17215, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13792, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "rewardsUnclaimed", "offset": 0, "slot": "3", diff --git a/deployments/polygon/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json b/deployments/polygon/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json new file mode 100644 index 0000000..ebd3212 --- /dev/null +++ b/deployments/polygon/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json @@ -0,0 +1,255 @@ +{ + "language": "Solidity", + "sources": { + "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n" + }, + "@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" + }, + "contracts/TwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\";\n\nimport \"./interfaces/ITwabRewards.sol\";\n\n/**\n * @title PoolTogether V4 TwabRewards\n * @author PoolTogether Inc Team\n * @notice Contract to distribute rewards to depositors in a pool.\n * This contract supports the creation of several promotions that can run simultaneously.\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\n * @dev This contract supports only one prize pool ticket.\n * @dev This contract does not support the use of fee on transfer tokens.\n */\ncontract TwabRewards is ITwabRewards {\n using SafeERC20 for IERC20;\n\n /* ============ Global Variables ============ */\n\n /// @notice Prize pool ticket for which the promotions are created.\n ITicket public immutable ticket;\n\n /// @notice Period during which the promotion owner can't destroy a promotion.\n uint32 public constant GRACE_PERIOD = 60 days;\n\n /// @notice Settings of each promotion.\n mapping(uint256 => Promotion) internal _promotions;\n\n /**\n * @notice Latest recorded promotion id.\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\n */\n uint256 internal _latestPromotionId;\n\n /**\n * @notice Keeps track of claimed rewards per user.\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\n */\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when a promotion is created.\n * @param promotionId Id of the newly created promotion\n */\n event PromotionCreated(uint256 indexed promotionId);\n\n /**\n * @notice Emitted when a promotion is ended.\n * @param promotionId Id of the promotion being ended\n * @param recipient Address of the recipient that will receive the remaining rewards\n * @param amount Amount of tokens transferred to the recipient\n * @param epochNumber Epoch number at which the promotion ended\n */\n event PromotionEnded(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount,\n uint8 epochNumber\n );\n\n /**\n * @notice Emitted when a promotion is destroyed.\n * @param promotionId Id of the promotion being destroyed\n * @param recipient Address of the recipient that will receive the unclaimed rewards\n * @param amount Amount of tokens transferred to the recipient\n */\n event PromotionDestroyed(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount\n );\n\n /**\n * @notice Emitted when a promotion is extended.\n * @param promotionId Id of the promotion being extended\n * @param numberOfEpochs Number of epochs the promotion has been extended by\n */\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\n\n /**\n * @notice Emitted when rewards have been claimed.\n * @param promotionId Id of the promotion for which epoch rewards were claimed\n * @param epochIds Ids of the epochs being claimed\n * @param user Address of the user for which the rewards were claimed\n * @param amount Amount of tokens transferred to the recipient address\n */\n event RewardsClaimed(\n uint256 indexed promotionId,\n uint8[] epochIds,\n address indexed user,\n uint256 amount\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor of the contract.\n * @param _ticket Prize Pool ticket address for which the promotions will be created\n */\n constructor(ITicket _ticket) {\n _requireTicket(_ticket);\n ticket = _ticket;\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITwabRewards\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external override returns (uint256) {\n require(_tokensPerEpoch > 0, \"TwabRewards/tokens-not-zero\");\n require(_epochDuration > 0, \"TwabRewards/duration-not-zero\");\n _requireNumberOfEpochs(_numberOfEpochs);\n\n uint256 _nextPromotionId = _latestPromotionId + 1;\n _latestPromotionId = _nextPromotionId;\n\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\n\n _promotions[_nextPromotionId] = Promotion({\n creator: msg.sender,\n startTimestamp: _startTimestamp,\n numberOfEpochs: _numberOfEpochs,\n epochDuration: _epochDuration,\n createdAt: uint48(block.timestamp),\n token: _token,\n tokensPerEpoch: _tokensPerEpoch,\n rewardsUnclaimed: _amount\n });\n\n uint256 _beforeBalance = _token.balanceOf(address(this));\n\n _token.safeTransferFrom(msg.sender, address(this), _amount);\n\n uint256 _afterBalance = _token.balanceOf(address(this));\n\n require(_beforeBalance + _amount == _afterBalance, \"TwabRewards/promo-amount-diff\");\n\n emit PromotionCreated(_nextPromotionId);\n\n return _nextPromotionId;\n }\n\n /// @inheritdoc ITwabRewards\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n _requirePromotionActive(_promotion);\n\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\n\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\n\n _promotion.token.safeTransfer(_to, _remainingRewards);\n\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\n uint256 _promotionCreatedAt = _promotion.createdAt;\n\n uint256 _gracePeriodEndTimestamp = (\n _promotionEndTimestamp < _promotionCreatedAt\n ? _promotionCreatedAt\n : _promotionEndTimestamp\n ) + GRACE_PERIOD;\n\n require(block.timestamp >= _gracePeriodEndTimestamp, \"TwabRewards/grace-period-active\");\n\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\n delete _promotions[_promotionId];\n\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\n\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\n external\n override\n returns (bool)\n {\n _requireNumberOfEpochs(_numberOfEpochs);\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionActive(_promotion);\n\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\n\n require(\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\n \"TwabRewards/epochs-over-limit\"\n );\n\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\n\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\n\n _promotions[_promotionId].rewardsUnclaimed += _amount;\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\n\n emit PromotionExtended(_promotionId, _numberOfEpochs);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external override returns (uint256) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _rewardsAmount;\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\n uint256 _epochIdsLength = _epochIds.length;\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n uint8 _epochId = _epochIds[index];\n\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \"TwabRewards/rewards-claimed\");\n\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\n\n _promotion.token.safeTransfer(_user, _rewardsAmount);\n\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\n\n return _rewardsAmount;\n }\n\n /// @inheritdoc ITwabRewards\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\n return _getPromotion(_promotionId);\n }\n\n /// @inheritdoc ITwabRewards\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\n return _getCurrentEpochId(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\n return _getRemainingRewards(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view override returns (uint256[] memory) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _epochIdsLength = _epochIds.length;\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\n _rewardsAmount[index] = 0;\n } else {\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\n }\n }\n\n return _rewardsAmount;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Determine if address passed is actually a ticket.\n * @param _ticket Address to check\n */\n function _requireTicket(ITicket _ticket) internal view {\n require(address(_ticket) != address(0), \"TwabRewards/ticket-not-zero-addr\");\n\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\n abi.encodePacked(_ticket.controller.selector)\n );\n\n require(\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\n \"TwabRewards/invalid-ticket\"\n );\n }\n\n /**\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\n * @param _numberOfEpochs Number of epochs to check\n */\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\n require(_numberOfEpochs > 0, \"TwabRewards/epochs-not-zero\");\n }\n\n /**\n * @notice Determine if a promotion is active.\n * @param _promotion Promotion to check\n */\n function _requirePromotionActive(Promotion memory _promotion) internal view {\n require(\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\n \"TwabRewards/promotion-inactive\"\n );\n }\n\n /**\n * @notice Determine if msg.sender is the promotion creator.\n * @param _promotion Promotion to check\n */\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\n require(msg.sender == _promotion.creator, \"TwabRewards/only-promo-creator\");\n }\n\n /**\n * @notice Get settings for a specific promotion.\n * @dev Will revert if the promotion does not exist.\n * @param _promotionId Promotion id to get settings for\n * @return Promotion settings\n */\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\n Promotion memory _promotion = _promotions[_promotionId];\n require(_promotion.creator != address(0), \"TwabRewards/invalid-promotion\");\n return _promotion;\n }\n\n /**\n * @notice Compute promotion end timestamp.\n * @param _promotion Promotion to compute end timestamp for\n * @return Promotion end timestamp\n */\n function _getPromotionEndTimestamp(Promotion memory _promotion)\n internal\n pure\n returns (uint256)\n {\n unchecked {\n return\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\n }\n }\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @dev We return the current epoch id if the promotion has not ended.\n * If the current timestamp is before the promotion start timestamp, we return 0.\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\n * @param _promotion Promotion to get current epoch for\n * @return Epoch id\n */\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\n uint256 _currentEpochId;\n\n if (block.timestamp > _promotion.startTimestamp) {\n unchecked {\n _currentEpochId =\n (block.timestamp - _promotion.startTimestamp) /\n _promotion.epochDuration;\n }\n }\n\n return _currentEpochId;\n }\n\n /**\n * @notice Get reward amount for a specific user.\n * @dev Rewards can only be calculated once the epoch is over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @param _user User to get reward amount for\n * @param _promotion Promotion from which the epoch is\n * @param _epochId Epoch id to get reward amount for\n * @return Reward amount\n */\n function _calculateRewardAmount(\n address _user,\n Promotion memory _promotion,\n uint8 _epochId\n ) internal view returns (uint256) {\n uint64 _epochDuration = _promotion.epochDuration;\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\n\n require(block.timestamp >= _epochEndTimestamp, \"TwabRewards/epoch-not-over\");\n require(_epochId < _promotion.numberOfEpochs, \"TwabRewards/invalid-epoch-id\");\n\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\n _user,\n _epochStartTimestamp,\n _epochEndTimestamp\n );\n\n if (_averageBalance > 0) {\n uint64[] memory _epochStartTimestamps = new uint64[](1);\n _epochStartTimestamps[0] = _epochStartTimestamp;\n\n uint64[] memory _epochEndTimestamps = new uint64[](1);\n _epochEndTimestamps[0] = _epochEndTimestamp;\n\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\n _epochStartTimestamps,\n _epochEndTimestamps\n )[0];\n\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\n }\n\n return 0;\n }\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\n return 0;\n }\n\n return\n _promotion.tokensPerEpoch *\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\n }\n\n /**\n * @notice Set boolean value for a specific epoch.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0011\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\n We get: 0000 0001 << 2 = 0000 0100\n We then OR the mask with the word to set the value.\n We get: 0110 0011 | 0000 0100 = 0110 0111\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\n * @param _epochId Id of the epoch to set the boolean for\n * @return Tightly packed epoch ids with the newly boolean value set\n */\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (uint256)\n {\n return _userClaimedEpochs | (uint256(1) << _epochId);\n }\n\n /**\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0111\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\n We get: 0110 0111 >> 2 = 0001 1001\n We then get the value of the last bit by masking with 1.\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\n We then return the boolean value true since the last bit is 1.\n * @param _userClaimedEpochs Record of epochs already claimed by the user\n * @param _epochId Epoch id to check\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\n */\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (bool)\n {\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\n }\n}\n" + }, + "@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" + }, + "@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" + }, + "contracts/interfaces/ITwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/**\n * @title PoolTogether V4 ITwabRewards\n * @author PoolTogether Inc Team\n * @notice TwabRewards contract interface.\n */\ninterface ITwabRewards {\n /**\n * @notice Struct to keep track of each promotion's settings.\n * @param creator Addresss of the promotion creator\n * @param startTimestamp Timestamp at which the promotion starts\n * @param numberOfEpochs Number of epochs the promotion will last for\n * @param epochDuration Duration of one epoch in seconds\n * @param createdAt Timestamp at which the promotion was created\n * @param token Address of the token to be distributed as reward\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\n */\n struct Promotion {\n address creator;\n uint64 startTimestamp;\n uint8 numberOfEpochs;\n uint48 epochDuration;\n uint48 createdAt;\n IERC20 token;\n uint256 tokensPerEpoch;\n uint256 rewardsUnclaimed;\n }\n\n /**\n * @notice Creates a new promotion.\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\n * So the first promotion will have id 1, the second 2, etc.\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\n * This scenario could happen if the token supplied is a fee on transfer one.\n * @param _token Address of the token to be distributed\n * @param _startTimestamp Timestamp at which the promotion starts\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\n * @param _epochDuration Duration of one epoch in seconds\n * @param _numberOfEpochs Number of epochs the promotion will last for\n * @return Id of the newly created promotion\n */\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external returns (uint256);\n\n /**\n * @notice End currently active promotion and send promotion tokens back to the creator.\n * @dev Will only send back tokens from the epochs that have not completed.\n * @param _promotionId Promotion id to end\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return true if operation was successful\n */\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\n * @dev Will send back all the tokens that have not been claimed yet by users.\n * @dev This function will revert if the promotion is still active.\n * @dev This function will revert if the grace period is not over yet.\n * @param _promotionId Promotion id to destroy\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return True if operation was successful\n */\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Extend promotion by adding more epochs.\n * @param _promotionId Id of the promotion to extend\n * @param _numberOfEpochs Number of epochs to add\n * @return True if the operation was successful\n */\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\n\n /**\n * @notice Claim rewards for a given promotion and epoch.\n * @dev Rewards can be claimed on behalf of a user.\n * @dev Rewards can only be claimed for a past epoch.\n * @param _user Address of the user to claim rewards for\n * @param _promotionId Id of the promotion to claim rewards for\n * @param _epochIds Epoch ids to claim rewards for\n * @return Total amount of rewards claimed\n */\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external returns (uint256);\n\n /**\n * @notice Get settings for a specific promotion.\n * @param _promotionId Id of the promotion to get settings for\n * @return Promotion settings\n */\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @param _promotionId Id of the promotion to get current epoch for\n * @return Current epoch id of the promotion\n */\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get amount of tokens to be rewarded for a given epoch.\n * @dev Rewards amount can only be retrieved for epochs that are over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @dev Will be 0 if user has already claimed rewards for the epoch.\n * @param _user Address of the user to get amount of rewards for\n * @param _promotionId Id of the promotion from which the epoch is\n * @param _epochIds Epoch ids to get reward amount for\n * @return Amount of tokens per epoch to be rewarded\n */\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view returns (uint256[] memory);\n}\n" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "contracts/PrizeTierHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"./interfaces/IPrizeTierHistory.sol\";\nimport \"./libraries/BinarySearchLib.sol\";\n\n/**\n * @title PoolTogether V4 PrizeTierHistory\n * @author PoolTogether Inc Team\n * @notice The PrizeTierHistory smart contract stores a history of PrizeTier structs linked to \n a range of valid Draw IDs. \n * @dev If the history param has single PrizeTier struct with a \"drawId\" of 1 all subsequent\n Draws will use that PrizeTier struct for PrizeDitribution calculations. The BinarySearchLib\n will find a PrizeTier using a \"atOrBefore\" range search when supplied drawId input parameter.\n */\ncontract PrizeTierHistory is IPrizeTierHistory, Manageable {\n\n // @dev The uint32[] type is extended with a binarySearch(uint32) function.\n using BinarySearchLib for uint32[];\n\n /**\n * @notice Ordered array of Draw IDs\n * @dev The history, with sequentially ordered ids, can be searched using binary search.\n The binary search will find index of a drawId (atOrBefore) using a specific drawId (at).\n When a new Draw ID is added to the history, a corresponding mapping of the ID is \n updated in the prizeTiers mapping.\n */\n uint32[] internal history;\n\n /**\n * @notice Mapping a Draw ID to a PrizeTier struct.\n * @dev The prizeTiers mapping links a Draw ID to a PrizeTier struct.\n The prizeTiers mapping is updated when a new Draw ID is added to the history.\n */\n mapping(uint32 => PrizeTier) internal prizeTiers;\n\n constructor(address owner) Ownable(owner) {}\n\n // @inheritdoc IPrizeTierHistory\n function count() external view override returns (uint256) {\n return history.length;\n }\n \n // @inheritdoc IPrizeTierHistory\n function getOldestDrawId() external view override returns (uint32) {\n return history[0];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getNewestDrawId() external view override returns (uint32) {\n return history[history.length - 1];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTier(uint32 drawId) override external view returns (PrizeTier memory) {\n require(drawId > 0, \"PrizeTierHistory/draw-id-not-zero\");\n return prizeTiers[history.binarySearch(drawId)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierList(uint32[] calldata _drawIds) override external view returns (PrizeTier[] memory) {\n uint256 _length = _drawIds.length; \n PrizeTier[] memory _data = new PrizeTier[](_length);\n for (uint256 index = 0; index < _length; index++) {\n _data[index] = prizeTiers[history.binarySearch(_drawIds[index])];\n }\n return _data;\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierAtIndex(uint256 index) external view override returns (PrizeTier memory) {\n return prizeTiers[uint32(index)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function push(PrizeTier calldata nextPrizeTier) override external onlyManagerOrOwner {\n _push(nextPrizeTier);\n }\n \n // @inheritdoc IPrizeTierHistory\n function popAndPush(PrizeTier calldata newPrizeTier) override external onlyOwner returns (uint32) {\n uint length = history.length;\n require(length > 0, \"PrizeTierHistory/history-empty\");\n require(history[length - 1] == newPrizeTier.drawId, \"PrizeTierHistory/invalid-draw-id\");\n _replace(newPrizeTier);\n return newPrizeTier.drawId;\n }\n\n // @inheritdoc IPrizeTierHistory\n function replace(PrizeTier calldata newPrizeTier) override external onlyOwner {\n _replace(newPrizeTier);\n }\n\n function _push(PrizeTier memory _prizeTier) internal {\n uint32 _length = uint32(history.length);\n if (_length > 0) {\n uint32 _id = history[_length - 1];\n require(\n _prizeTier.drawId > _id,\n \"PrizeTierHistory/non-sequential-id\"\n );\n }\n history.push(_prizeTier.drawId);\n prizeTiers[_length] = _prizeTier;\n emit PrizeTierPushed(_prizeTier.drawId, _prizeTier);\n }\n\n function _replace(PrizeTier calldata _prizeTier) internal {\n uint256 cardinality = history.length;\n require(cardinality > 0, \"PrizeTierHistory/no-prize-tiers\");\n uint32 oldestDrawId = history[0];\n require(_prizeTier.drawId >= oldestDrawId, \"PrizeTierHistory/draw-id-out-of-range\");\n uint32 index = history.binarySearch(_prizeTier.drawId);\n require(history[index] == _prizeTier.drawId, \"PrizeTierHistory/draw-id-must-match\");\n prizeTiers[index] = _prizeTier;\n emit PrizeTierSet(_prizeTier.drawId, _prizeTier);\n }\n}\n" + }, + "contracts/libraries/BinarySearchLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\n\n/**\n * @title PoolTogether V4 BinarySearchLib\n * @author PoolTogether Inc Team\n * @notice BinarySearchLib uses binary search to find a parent contract struct with the drawId parameter\n * @dev The implementing contract must provider access to a struct (i.e. PrizeTier) list with is both\n * sorted and indexed by the drawId field for binary search to work.\n */\nlibrary BinarySearchLib {\n\n /**\n * @notice Find ID in array of ordered IDs using Binary Search.\n * @param _history uin32[] - Array of IDsq\n * @param _drawId uint32 - Draw ID to search for\n * @return uint32 - Index of ID in array\n */\n function binarySearch(uint32[] storage _history, uint32 _drawId) internal view returns (uint32) {\n uint32 index;\n uint32 leftSide = 0;\n uint32 rightSide = uint32(_history.length - 1);\n\n uint32 oldestDrawId = _history[0];\n uint32 newestDrawId = _history[rightSide];\n\n require(_drawId >= oldestDrawId, \"BinarySearchLib/draw-id-out-of-range\");\n if (_drawId >= newestDrawId) return rightSide;\n if (_drawId == oldestDrawId) return leftSide;\n\n while (true) {\n uint32 length = rightSide - leftSide;\n uint32 center = leftSide + (length / 2);\n uint32 centerID = _history[center];\n\n if (centerID == _drawId) {\n index = center;\n break;\n }\n\n if (length <= 1) {\n if(_history[rightSide] <= _drawId) {\n index = rightSide;\n } else {\n index = leftSide;\n }\n break;\n }\n \n if (centerID < _drawId) {\n leftSide = center;\n } else {\n rightSide = center - 1;\n }\n }\n\n return index;\n }\n}\n" + }, + "contracts/test/BinarySearchLibHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"../libraries/BinarySearchLib.sol\";\n\ncontract BinarySearchLibHarness {\n using BinarySearchLib for uint32[];\n uint32[] internal history;\n\n function getIndex(uint32 id) external view returns (uint32)\n {\n return history.binarySearch(id);\n }\n \n function getIndexes(uint32[] calldata ids) external view returns (uint32[] memory)\n {\n uint32[] memory data = new uint32[](ids.length);\n for (uint256 i = 0; i < ids.length; i++) {\n data[i] = history.binarySearch(ids[i]);\n }\n return data;\n }\n\n function set(uint32[] calldata _history) external\n {\n history = _history;\n }\n}\n" + }, + "contracts/PrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./interfaces/IPrizeFlush.sol\";\n\n/**\n * @title PoolTogether V4 PrizeFlush\n * @author PoolTogether Inc Team\n * @notice The PrizeFlush contract helps capture interest from the PrizePool and move collected funds\n to a designated PrizeDistributor contract. When deployed, the destination, reserve and strategy\n addresses are set and used as static parameters during every \"flush\" execution. The parameters can be\n reset by the Owner if necessary.\n */\ncontract PrizeFlush is IPrizeFlush, Manageable {\n /**\n * @notice Destination address for captured interest.\n * @dev Should be set to the PrizeDistributor address.\n */\n address internal destination;\n\n /// @notice Reserve address.\n IReserve internal reserve;\n\n /// @notice Strategy address.\n IStrategy internal strategy;\n\n /**\n * @notice Emitted when contract has been deployed.\n * @param destination Destination address\n * @param reserve Strategy address\n * @param strategy Reserve address\n *\n */\n event Deployed(\n address indexed destination,\n IReserve indexed reserve,\n IStrategy indexed strategy\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy Prize Flush.\n * @param _owner Prize Flush owner address\n * @param _destination Destination address\n * @param _strategy Strategy address\n * @param _reserve Reserve address\n *\n */\n constructor(\n address _owner,\n address _destination,\n IStrategy _strategy,\n IReserve _reserve\n ) Ownable(_owner) {\n _setDestination(_destination);\n _setReserve(_reserve);\n _setStrategy(_strategy);\n\n emit Deployed(_destination, _reserve, _strategy);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeFlush\n function getDestination() external view override returns (address) {\n return destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function getReserve() external view override returns (IReserve) {\n return reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function getStrategy() external view override returns (IStrategy) {\n return strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function setDestination(address _destination) external override onlyOwner returns (address) {\n _setDestination(_destination);\n emit DestinationSet(_destination);\n return _destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function setReserve(IReserve _reserve) external override onlyOwner returns (IReserve) {\n _setReserve(_reserve);\n emit ReserveSet(_reserve);\n return _reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function setStrategy(IStrategy _strategy) external override onlyOwner returns (IStrategy) {\n _setStrategy(_strategy);\n emit StrategySet(_strategy);\n return _strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function flush() external override onlyManagerOrOwner returns (bool) {\n // Captures interest from PrizePool and distributes funds using a PrizeSplitStrategy.\n strategy.distribute();\n\n // After funds are distributed using PrizeSplitStrategy we EXPECT funds to be located in the Reserve.\n IReserve _reserve = reserve;\n IERC20 _token = _reserve.getToken();\n uint256 _amount = _token.balanceOf(address(_reserve));\n\n // IF the tokens were succesfully moved to the Reserve, now move them to the destination (PrizeDistributor) address.\n if (_amount > 0) {\n address _destination = destination;\n\n // Create checkpoint and transfers new total balance to PrizeDistributor\n _reserve.withdrawTo(_destination, _amount);\n\n emit Flushed(_destination, _amount);\n return true;\n }\n\n return false;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Set global destination variable.\n * @dev `_destination` cannot be the zero address.\n * @param _destination Destination address\n */\n function _setDestination(address _destination) internal {\n require(_destination != address(0), \"Flush/destination-not-zero-address\");\n destination = _destination;\n }\n\n /**\n * @notice Set global reserve variable.\n * @dev `_reserve` cannot be the zero address.\n * @param _reserve Reserve address\n */\n function _setReserve(IReserve _reserve) internal {\n require(address(_reserve) != address(0), \"Flush/reserve-not-zero-address\");\n reserve = _reserve;\n }\n\n /**\n * @notice Set global strategy variable.\n * @dev `_strategy` cannot be the zero address.\n * @param _strategy Strategy address\n */\n function _setStrategy(IStrategy _strategy) internal {\n require(address(_strategy) != address(0), \"Flush/strategy-not-zero-address\");\n strategy = _strategy;\n }\n}\n" + }, + "contracts/interfaces/IPrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IReserve.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/IStrategy.sol\";\n\ninterface IPrizeFlush {\n /**\n * @notice Emit when the flush function has executed.\n * @param destination Address receiving funds\n * @param amount Amount of tokens transferred\n */\n event Flushed(address indexed destination, uint256 amount);\n\n /**\n * @notice Emit when destination is set.\n * @param destination Destination address\n */\n event DestinationSet(address destination);\n\n /**\n * @notice Emit when strategy is set.\n * @param strategy Strategy address\n */\n event StrategySet(IStrategy strategy);\n\n /**\n * @notice Emit when reserve is set.\n * @param reserve Reserve address\n */\n event ReserveSet(IReserve reserve);\n\n /// @notice Read global destination variable.\n function getDestination() external view returns (address);\n\n /// @notice Read global reserve variable.\n function getReserve() external view returns (IReserve);\n\n /// @notice Read global strategy variable.\n function getStrategy() external view returns (IStrategy);\n\n /// @notice Set global destination variable.\n function setDestination(address _destination) external returns (address);\n\n /// @notice Set global reserve variable.\n function setReserve(IReserve _reserve) external returns (IReserve);\n\n /// @notice Set global strategy variable.\n function setStrategy(IStrategy _strategy) external returns (IStrategy);\n\n /**\n * @notice Migrate interest from PrizePool to PrizeDistributor in a single transaction.\n * @dev Captures interest, checkpoint data and transfers tokens to final destination.\n * @return True if operation is successful.\n */\n function flush() external returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total depsosited\n * @param withdrawAccumulated Total withdrawn\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./PrizeSplit.sol\";\nimport \"../interfaces/IStrategy.sol\";\nimport \"../interfaces/IPrizePool.sol\";\n\n/**\n * @title PoolTogether V4 PrizeSplitStrategy\n * @author PoolTogether Inc Team\n * @notice Captures PrizePool interest for PrizeReserve and additional PrizeSplit recipients.\n The PrizeSplitStrategy will have at minimum a single PrizeSplit with 100% of the captured\n interest transfered to the PrizeReserve. Additional PrizeSplits can be added, depending on\n the deployers requirements (i.e. percentage to charity). In contrast to previous PoolTogether\n iterations, interest can be captured independent of a new Draw. Ideally (to save gas) interest\n is only captured when also distributing the captured prize(s) to applicable Prize Distributor(s).\n*/\ncontract PrizeSplitStrategy is PrizeSplit, IStrategy {\n /**\n * @notice PrizePool address\n */\n IPrizePool internal immutable prizePool;\n\n /**\n * @notice Deployed Event\n * @param owner Contract owner\n * @param prizePool Linked PrizePool contract\n */\n event Deployed(address indexed owner, IPrizePool prizePool);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy the PrizeSplitStrategy smart contract.\n * @param _owner Owner address\n * @param _prizePool PrizePool address\n */\n constructor(address _owner, IPrizePool _prizePool) Ownable(_owner) {\n require(\n address(_prizePool) != address(0),\n \"PrizeSplitStrategy/prize-pool-not-zero-address\"\n );\n prizePool = _prizePool;\n emit Deployed(_owner, _prizePool);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IStrategy\n function distribute() external override returns (uint256) {\n uint256 prize = prizePool.captureAwardBalance();\n\n if (prize == 0) return 0;\n\n uint256 prizeRemaining = _distributePrizeSplits(prize);\n\n emit Distributed(prize - prizeRemaining);\n\n return prize;\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizePool() external view override returns (IPrizePool) {\n return prizePool;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Award ticket tokens to prize split recipient.\n * @dev Award ticket tokens to prize split recipient via the linked PrizePool contract.\n * @param _to Recipient of minted tokens.\n * @param _amount Amount of minted tokens.\n */\n function _awardPrizeSplitAmount(address _to, uint256 _amount) internal override {\n IControlledToken _ticket = prizePool.getTicket();\n prizePool.award(_to, _amount);\n emit PrizeSplitAwarded(_to, _amount, _ticket);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../interfaces/IPrizeSplit.sol\";\n\n/**\n * @title PrizeSplit Interface\n * @author PoolTogether Inc Team\n */\nabstract contract PrizeSplit is IPrizeSplit, Ownable {\n /* ============ Global Variables ============ */\n PrizeSplitConfig[] internal _prizeSplits;\n\n uint16 public constant ONE_AS_FIXED_POINT_3 = 1000;\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplit(uint256 _prizeSplitIndex)\n external\n view\n override\n returns (PrizeSplitConfig memory)\n {\n return _prizeSplits[_prizeSplitIndex];\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplits() external view override returns (PrizeSplitConfig[] memory) {\n return _prizeSplits;\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplits(PrizeSplitConfig[] calldata _newPrizeSplits)\n external\n override\n onlyOwner\n {\n uint256 newPrizeSplitsLength = _newPrizeSplits.length;\n require(newPrizeSplitsLength <= type(uint8).max, \"PrizeSplit/invalid-prizesplits-length\");\n\n // Add and/or update prize split configs using _newPrizeSplits PrizeSplitConfig structs array.\n for (uint256 index = 0; index < newPrizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _newPrizeSplits[index];\n\n // REVERT when setting the canonical burn address.\n require(split.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // IF the CURRENT prizeSplits length is below the NEW prizeSplits\n // PUSH the PrizeSplit struct to end of the list.\n if (_prizeSplits.length <= index) {\n _prizeSplits.push(split);\n } else {\n // ELSE update an existing PrizeSplit struct with new parameters\n PrizeSplitConfig memory currentSplit = _prizeSplits[index];\n\n // IF new PrizeSplit DOES NOT match the current PrizeSplit\n // WRITE to STORAGE with the new PrizeSplit\n if (\n split.target != currentSplit.target ||\n split.percentage != currentSplit.percentage\n ) {\n _prizeSplits[index] = split;\n } else {\n continue;\n }\n }\n\n // Emit the added/updated prize split config.\n emit PrizeSplitSet(split.target, split.percentage, index);\n }\n\n // Remove old prize splits configs. Match storage _prizesSplits.length with the passed newPrizeSplits.length\n while (_prizeSplits.length > newPrizeSplitsLength) {\n uint256 _index;\n unchecked {\n _index = _prizeSplits.length - 1;\n }\n _prizeSplits.pop();\n emit PrizeSplitRemoved(_index);\n }\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplit(PrizeSplitConfig memory _prizeSplit, uint8 _prizeSplitIndex)\n external\n override\n onlyOwner\n {\n require(_prizeSplitIndex < _prizeSplits.length, \"PrizeSplit/nonexistent-prizesplit\");\n require(_prizeSplit.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // Update the prize split config\n _prizeSplits[_prizeSplitIndex] = _prizeSplit;\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n\n // Emit updated prize split config\n emit PrizeSplitSet(\n _prizeSplit.target,\n _prizeSplit.percentage,\n _prizeSplitIndex\n );\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Calculates total prize split percentage amount.\n * @dev Calculates total PrizeSplitConfig percentage(s) amount. Used to check the total does not exceed 100% of award distribution.\n * @return Total prize split(s) percentage amount\n */\n function _totalPrizeSplitPercentageAmount() internal view returns (uint256) {\n uint256 _tempTotalPercentage;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n _tempTotalPercentage += _prizeSplits[index].percentage;\n }\n\n return _tempTotalPercentage;\n }\n\n /**\n * @notice Distributes prize split(s).\n * @dev Distributes prize split(s) by awarding ticket or sponsorship tokens.\n * @param _prize Starting prize award amount\n * @return The remainder after splits are taken\n */\n function _distributePrizeSplits(uint256 _prize) internal returns (uint256) {\n uint256 _prizeTemp = _prize;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _prizeSplits[index];\n uint256 _splitAmount = (_prize * split.percentage) / 1000;\n\n // Award the prize split distribution amount.\n _awardPrizeSplitAmount(split.target, _splitAmount);\n\n // Update the remaining prize amount after distributing the prize split percentage.\n _prizeTemp -= _splitAmount;\n }\n\n return _prizeTemp;\n }\n\n /**\n * @notice Mints ticket or sponsorship tokens to prize split recipient.\n * @dev Mints ticket or sponsorship tokens to prize split recipient via the linked PrizePool contract.\n * @param _target Recipient of minted tokens\n * @param _amount Amount of minted tokens\n */\n function _awardPrizeSplitAmount(address _target, uint256 _amount) internal virtual;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/ITicket.sol\";\n\ninterface IPrizePool {\n /// @dev Event emitted when controlled token is added\n event ControlledTokenAdded(ITicket indexed token);\n\n event AwardCaptured(uint256 amount);\n\n /// @dev Event emitted when assets are deposited\n event Deposited(\n address indexed operator,\n address indexed to,\n ITicket indexed token,\n uint256 amount\n );\n\n /// @dev Event emitted when interest is awarded to a winner\n event Awarded(address indexed winner, ITicket indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are awarded to a winner\n event AwardedExternalERC20(address indexed winner, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are transferred out\n event TransferredExternalERC20(address indexed to, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC721s are awarded to a winner\n event AwardedExternalERC721(address indexed winner, address indexed token, uint256[] tokenIds);\n\n /// @dev Event emitted when assets are withdrawn\n event Withdrawal(\n address indexed operator,\n address indexed from,\n ITicket indexed token,\n uint256 amount,\n uint256 redeemed\n );\n\n /// @dev Event emitted when the Balance Cap is set\n event BalanceCapSet(uint256 balanceCap);\n\n /// @dev Event emitted when the Liquidity Cap is set\n event LiquidityCapSet(uint256 liquidityCap);\n\n /// @dev Event emitted when the Prize Strategy is set\n event PrizeStrategySet(address indexed prizeStrategy);\n\n /// @dev Event emitted when the Ticket is set\n event TicketSet(ITicket indexed ticket);\n\n /// @dev Emitted when there was an error thrown awarding an External ERC721\n event ErrorAwardingExternalERC721(bytes error);\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n function depositTo(address to, uint256 amount) external;\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens,\n /// then sets the delegate on behalf of the caller.\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n /// @param delegate The address to delegate to for the caller\n function depositToAndDelegate(address to, uint256 amount, address delegate) external;\n\n /// @notice Withdraw assets from the Prize Pool instantly.\n /// @param from The address to redeem tokens from.\n /// @param amount The amount of tokens to redeem for assets.\n /// @return The actual amount withdrawn\n function withdrawFrom(address from, uint256 amount) external returns (uint256);\n\n /// @notice Called by the prize strategy to award prizes.\n /// @dev The amount awarded must be less than the awardBalance()\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of assets to be awarded\n function award(address to, uint256 amount) external;\n\n /// @notice Returns the balance that is available to award.\n /// @dev captureAwardBalance() should be called first\n /// @return The total amount of assets to be awarded for the current prize\n function awardBalance() external view returns (uint256);\n\n /// @notice Captures any available interest as award balance.\n /// @dev This function also captures the reserve fees.\n /// @return The total amount of assets to be awarded for the current prize\n function captureAwardBalance() external returns (uint256);\n\n /// @dev Checks with the Prize Pool if a specific token type may be awarded as an external prize\n /// @param externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function canAwardExternal(address externalToken) external view returns (bool);\n\n // @dev Returns the total underlying balance of all assets. This includes both principal and interest.\n /// @return The underlying balance of assets\n function balance() external returns (uint256);\n\n /**\n * @notice Read internal Ticket accounted balance.\n * @return uint256 accountBalance\n */\n function getAccountedBalance() external view returns (uint256);\n\n /**\n * @notice Read internal balanceCap variable\n */\n function getBalanceCap() external view returns (uint256);\n\n /**\n * @notice Read internal liquidityCap variable\n */\n function getLiquidityCap() external view returns (uint256);\n\n /**\n * @notice Read ticket variable\n */\n function getTicket() external view returns (ITicket);\n\n /**\n * @notice Read token variable\n */\n function getToken() external view returns (address);\n\n /**\n * @notice Read prizeStrategy variable\n */\n function getPrizeStrategy() external view returns (address);\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function isControlled(ITicket controlledToken) external view returns (bool);\n\n /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens\n /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything.\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external asset token being awarded\n /// @param amount The amount of external assets to be awarded\n function transferExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the Prize-Strategy to award external ERC20 prizes\n /// @dev Used to award any arbitrary tokens held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of external assets to be awarded\n /// @param externalToken The address of the external asset token being awarded\n function awardExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the prize strategy to award external ERC721 prizes\n /// @dev Used to award any arbitrary NFTs held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external NFT token being awarded\n /// @param tokenIds An array of NFT Token IDs to be transferred\n function awardExternalERC721(\n address to,\n address externalToken,\n uint256[] calldata tokenIds\n ) external;\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @dev If a user wins, his balance can go over the cap. He will be able to withdraw the excess but not deposit.\n /// @dev Needs to be called after deploying a prize pool to be able to deposit into it.\n /// @param balanceCap New balance cap.\n /// @return True if new balance cap has been successfully set.\n function setBalanceCap(uint256 balanceCap) external returns (bool);\n\n /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold\n /// @param liquidityCap The new liquidity cap for the prize pool\n function setLiquidityCap(uint256 liquidityCap) external;\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy.\n function setPrizeStrategy(address _prizeStrategy) external;\n\n /// @notice Set prize pool ticket.\n /// @param ticket Address of the ticket to set.\n /// @return True if ticket has been successfully set.\n function setTicket(ITicket ticket) external returns (bool);\n\n /// @notice Delegate the votes for a Compound COMP-like token held by the prize pool\n /// @param compLike The COMP-like token held by the prize pool that should be delegated\n /// @param to The address to delegate to\n function compLikeDelegate(ICompLike compLike, address to) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./IControlledToken.sol\";\nimport \"./IPrizePool.sol\";\n\n/**\n * @title Abstract prize split contract for adding unique award distribution to static addresses.\n * @author PoolTogether Inc Team\n */\ninterface IPrizeSplit {\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice The prize split configuration struct.\n * @dev The prize split configuration struct used to award prize splits during distribution.\n * @param target Address of recipient receiving the prize split distribution\n * @param percentage Percentage of prize split using a 0-1000 range for single decimal precision i.e. 125 = 12.5%\n */\n struct PrizeSplitConfig {\n address target;\n uint16 percentage;\n }\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is added or updated.\n * @dev Emitted when a PrizeSplitConfig config is added or updated in setPrizeSplits or setPrizeSplit.\n * @param target Address of prize split recipient\n * @param percentage Percentage of prize split. Must be between 0 and 1000 for single decimal precision\n * @param index Index of prize split in the prizeSplts array\n */\n event PrizeSplitSet(address indexed target, uint16 percentage, uint256 index);\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is removed.\n * @dev Emitted when a PrizeSplitConfig config is removed from the prizeSplits array.\n * @param target Index of a previously active prize split config\n */\n event PrizeSplitRemoved(uint256 indexed target);\n\n /**\n * @notice Read prize split config from active PrizeSplits.\n * @dev Read PrizeSplitConfig struct from prizeSplits array.\n * @param prizeSplitIndex Index position of PrizeSplitConfig\n * @return PrizeSplitConfig Single prize split config\n */\n function getPrizeSplit(uint256 prizeSplitIndex) external view returns (PrizeSplitConfig memory);\n\n /**\n * @notice Read all prize splits configs.\n * @dev Read all PrizeSplitConfig structs stored in prizeSplits.\n * @return Array of PrizeSplitConfig structs\n */\n function getPrizeSplits() external view returns (PrizeSplitConfig[] memory);\n\n /**\n * @notice Get PrizePool address\n * @return IPrizePool\n */\n function getPrizePool() external view returns (IPrizePool);\n\n /**\n * @notice Set and remove prize split(s) configs. Only callable by owner.\n * @dev Set and remove prize split configs by passing a new PrizeSplitConfig structs array. Will remove existing PrizeSplitConfig(s) if passed array length is less than existing prizeSplits length.\n * @param newPrizeSplits Array of PrizeSplitConfig structs\n */\n function setPrizeSplits(PrizeSplitConfig[] calldata newPrizeSplits) external;\n\n /**\n * @notice Updates a previously set prize split config.\n * @dev Updates a prize split config by passing a new PrizeSplitConfig struct and current index position. Limited to contract owner.\n * @param prizeStrategySplit PrizeSplitConfig config struct\n * @param prizeSplitIndex Index position of PrizeSplitConfig to update\n */\n function setPrizeSplit(PrizeSplitConfig memory prizeStrategySplit, uint8 prizeSplitIndex)\n external;\n}\n" + }, + "@pooltogether/v4-core/contracts/external/compound/ICompLike.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ICompLike is IERC20 {\n function getCurrentVotes(address account) external view returns (uint96);\n\n function delegate(address delegate) external;\n}\n" + }, + "contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IControlledToken.sol\";\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/ControlledToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\nimport \"./interfaces/IControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Controlled ERC20 Token\n * @author PoolTogether Inc Team\n * @notice ERC20 Tokens with a controller for minting & burning\n */\ncontract ControlledToken is ERC20Permit, IControlledToken {\n /* ============ Global Variables ============ */\n\n /// @notice Interface to the contract responsible for controlling mint/burn\n address public override immutable controller;\n\n /// @notice ERC20 controlled token decimals.\n uint8 private immutable _decimals;\n\n /* ============ Events ============ */\n\n /// @dev Emitted when contract is deployed\n event Deployed(string name, string symbol, uint8 decimals, address indexed controller);\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure that the caller is the controller contract\n modifier onlyController() {\n require(msg.sender == address(controller), \"ControlledToken/only-controller\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Controlled Token with Token Details and the Controller\n /// @param _name The name of the Token\n /// @param _symbol The symbol for the Token\n /// @param decimals_ The number of decimals for the Token\n /// @param _controller Address of the Controller contract for minting & burning\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ERC20Permit(\"PoolTogether ControlledToken\") ERC20(_name, _symbol) {\n require(address(_controller) != address(0), \"ControlledToken/controller-not-zero-address\");\n controller = _controller;\n\n require(decimals_ > 0, \"ControlledToken/decimals-gt-zero\");\n _decimals = decimals_;\n\n emit Deployed(_name, _symbol, decimals_, _controller);\n }\n\n /* ============ External Functions ============ */\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 function controllerMint(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _mint(_user, _amount);\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 function controllerBurn(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _burn(_user, _amount);\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 function controllerBurnFrom(\n address _operator,\n address _user,\n uint256 _amount\n ) external virtual override onlyController {\n if (_operator != _user) {\n _approve(_user, _operator, allowance(_user, _operator) - _amount);\n }\n\n _burn(_user, _amount);\n }\n\n /// @notice Returns the ERC20 controlled token decimals.\n /// @dev This value should be equal to the decimals of the token used to deposit into the pool.\n /// @return uint8 decimals.\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n\n _afterTokenTransfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s;\n uint8 v;\n assembly {\n s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\n v := add(shr(255, vs), 27)\n }\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/**\n * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},\n * which have permission to mint (create) new tokens as they see fit.\n *\n * At construction, the deployer of the contract is the only minter.\n */\ncontract ERC20Mintable is ERC20 {\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}\n\n /**\n * @dev See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the {MinterRole}.\n */\n function mint(address account, uint256 amount) public {\n _mint(account, amount);\n }\n\n function burn(address account, uint256 amount) public returns (bool) {\n _burn(account, amount);\n return true;\n }\n\n function masterTransfer(\n address from,\n address to,\n uint256 amount\n ) public {\n _transfer(from, to, amount);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../Reserve.sol\";\nimport \"./ERC20Mintable.sol\";\n\ncontract ReserveHarness is Reserve {\n constructor(address _owner, IERC20 _token) Reserve(_owner, _token) {}\n\n function setObservationsAt(ObservationLib.Observation[] calldata observations) external {\n for (uint256 i = 0; i < observations.length; i++) {\n reserveAccumulators[i] = observations[i];\n }\n\n nextIndex = uint24(observations.length);\n cardinality = uint24(observations.length);\n }\n\n function doubleCheckpoint(ERC20Mintable _token, uint256 _amount) external {\n _checkpoint();\n _token.mint(address(this), _amount);\n _checkpoint();\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/Reserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./interfaces/IReserve.sol\";\nimport \"./libraries/ObservationLib.sol\";\nimport \"./libraries/RingBufferLib.sol\";\n\n/**\n * @title PoolTogether V4 Reserve\n * @author PoolTogether Inc Team\n * @notice The Reserve contract provides historical lookups of a token balance increase during a target timerange.\n As the Reserve contract transfers OUT tokens, the withdraw accumulator is increased. When tokens are\n transfered IN new checkpoint *can* be created if checkpoint() is called after transfering tokens.\n By using the reserve and withdraw accumulators to create a new checkpoint, any contract or account\n can lookup the balance increase of the reserve for a target timerange. \n * @dev By calculating the total held tokens in a specific time range, contracts that require knowledge \n of captured interest during a draw period, can easily call into the Reserve and deterministically\n determine the newly aqcuired tokens for that time range. \n */\ncontract Reserve is IReserve, Manageable {\n using SafeERC20 for IERC20;\n\n /// @notice ERC20 token\n IERC20 public immutable token;\n\n /// @notice Total withdraw amount from reserve\n uint224 public withdrawAccumulator;\n uint32 private _gap;\n\n uint24 internal nextIndex;\n uint24 internal cardinality;\n\n /// @notice The maximum number of twab entries\n uint24 internal constant MAX_CARDINALITY = 16777215; // 2**24 - 1\n\n ObservationLib.Observation[MAX_CARDINALITY] internal reserveAccumulators;\n\n /* ============ Events ============ */\n\n event Deployed(IERC20 indexed token);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _owner Owner address\n * @param _token ERC20 address\n */\n constructor(address _owner, IERC20 _token) Ownable(_owner) {\n token = _token;\n emit Deployed(_token);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IReserve\n function checkpoint() external override {\n _checkpoint();\n }\n\n /// @inheritdoc IReserve\n function getToken() external view override returns (IERC20) {\n return token;\n }\n\n /// @inheritdoc IReserve\n function getReserveAccumulatedBetween(uint32 _startTimestamp, uint32 _endTimestamp)\n external\n view\n override\n returns (uint224)\n {\n require(_startTimestamp < _endTimestamp, \"Reserve/start-less-then-end\");\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n\n (uint24 _newestIndex, ObservationLib.Observation memory _newestObservation) = _getNewestObservation(_nextIndex);\n (uint24 _oldestIndex, ObservationLib.Observation memory _oldestObservation) = _getOldestObservation(_nextIndex);\n\n uint224 _start = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _startTimestamp\n );\n\n uint224 _end = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _endTimestamp\n );\n\n return _end - _start;\n }\n\n /// @inheritdoc IReserve\n function withdrawTo(address _recipient, uint256 _amount) external override onlyManagerOrOwner {\n _checkpoint();\n\n withdrawAccumulator += uint224(_amount);\n \n token.safeTransfer(_recipient, _amount);\n\n emit Withdrawn(_recipient, _amount);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Find optimal observation checkpoint using target timestamp\n * @dev Uses binary search if target timestamp is within ring buffer range.\n * @param _newestObservation ObservationLib.Observation\n * @param _oldestObservation ObservationLib.Observation\n * @param _newestIndex The index of the newest observation\n * @param _oldestIndex The index of the oldest observation\n * @param _cardinality RingBuffer Range\n * @param _timestamp Timestamp target\n *\n * @return Optimal reserveAccumlator for timestamp.\n */\n function _getReserveAccumulatedAt(\n ObservationLib.Observation memory _newestObservation,\n ObservationLib.Observation memory _oldestObservation,\n uint24 _newestIndex,\n uint24 _oldestIndex,\n uint24 _cardinality,\n uint32 _timestamp\n ) internal view returns (uint224) {\n uint32 timeNow = uint32(block.timestamp);\n\n // IF empty ring buffer exit early.\n if (_cardinality == 0) return 0;\n\n /**\n * Ring Buffer Search Optimization\n * Before performing binary search on the ring buffer check\n * to see if timestamp is within range of [o T n] by comparing\n * the target timestamp to the oldest/newest observation.timestamps\n * IF the timestamp is out of the ring buffer range avoid starting\n * a binary search, because we can return NULL or oldestObservation.amount\n */\n\n /**\n * IF oldestObservation.timestamp is after timestamp: T[old ]\n * the Reserve did NOT have a balance or the ring buffer\n * no longer contains that timestamp checkpoint.\n */\n if (_oldestObservation.timestamp > _timestamp) {\n return 0;\n }\n\n /**\n * IF newestObservation.timestamp is before timestamp: [ new]T\n * return _newestObservation.amount since observation\n * contains the highest checkpointed reserveAccumulator.\n */\n if (_newestObservation.timestamp <= _timestamp) {\n return _newestObservation.amount;\n }\n\n // IF the timestamp is witin range of ring buffer start/end: [new T old]\n // FIND the closest observation to the left(or exact) of timestamp: [OT ]\n (\n ObservationLib.Observation memory beforeOrAt,\n ObservationLib.Observation memory atOrAfter\n ) = ObservationLib.binarySearch(\n reserveAccumulators,\n _newestIndex,\n _oldestIndex,\n _timestamp,\n _cardinality,\n timeNow\n );\n\n // IF target timestamp is EXACT match for atOrAfter.timestamp observation return amount.\n // NOT having an exact match with atOrAfter means values will contain accumulator value AFTER the searchable range.\n // ELSE return observation.totalDepositedAccumulator closest to LEFT of target timestamp.\n if (atOrAfter.timestamp == _timestamp) {\n return atOrAfter.amount;\n } else {\n return beforeOrAt.amount;\n }\n }\n\n /// @notice Records the currently accrued reserve amount.\n function _checkpoint() internal {\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n uint256 _balanceOfReserve = token.balanceOf(address(this));\n uint224 _withdrawAccumulator = withdrawAccumulator; //sload\n (uint24 newestIndex, ObservationLib.Observation memory newestObservation) = _getNewestObservation(_nextIndex);\n\n /**\n * IF tokens have been deposited into Reserve contract since the last checkpoint\n * create a new Reserve balance checkpoint. The will will update multiple times in a single block.\n */\n if (_balanceOfReserve + _withdrawAccumulator > newestObservation.amount) {\n uint32 nowTime = uint32(block.timestamp);\n\n // checkpointAccumulator = currentBalance + totalWithdraws\n uint224 newReserveAccumulator = uint224(_balanceOfReserve) + _withdrawAccumulator;\n\n // IF newestObservation IS NOT in the current block.\n // CREATE observation in the accumulators ring buffer.\n if (newestObservation.timestamp != nowTime) {\n reserveAccumulators[_nextIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n nextIndex = uint24(RingBufferLib.nextIndex(_nextIndex, MAX_CARDINALITY));\n if (_cardinality < MAX_CARDINALITY) {\n cardinality = _cardinality + 1;\n }\n }\n // ELSE IF newestObservation IS in the current block.\n // UPDATE the checkpoint previously created in block history.\n else {\n reserveAccumulators[newestIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n }\n\n emit Checkpoint(newReserveAccumulator, _withdrawAccumulator);\n }\n }\n\n /// @notice Retrieves the oldest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getOldestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = _nextIndex;\n observation = reserveAccumulators[index];\n\n // If the TWAB is not initialized we go to the beginning of the TWAB circular buffer at index 0\n if (observation.timestamp == 0) {\n index = 0;\n observation = reserveAccumulators[0];\n }\n }\n\n /// @notice Retrieves the newest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getNewestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = uint24(RingBufferLib.newestIndex(_nextIndex, MAX_CARDINALITY));\n observation = reserveAccumulators[index];\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/libraries/DrawRingBufferLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./RingBufferLib.sol\";\n\n/// @title Library for creating and managing a draw ring buffer.\nlibrary DrawRingBufferLib {\n /// @notice Draw buffer struct.\n struct Buffer {\n uint32 lastDrawId;\n uint32 nextIndex;\n uint32 cardinality;\n }\n\n /// @notice Helper function to know if the draw ring buffer has been initialized.\n /// @dev since draws start at 1 and are monotonically increased, we know we are uninitialized if nextIndex = 0 and lastDrawId = 0.\n /// @param _buffer The buffer to check.\n function isInitialized(Buffer memory _buffer) internal pure returns (bool) {\n return !(_buffer.nextIndex == 0 && _buffer.lastDrawId == 0);\n }\n\n /// @notice Push a draw to the buffer.\n /// @param _buffer The buffer to push to.\n /// @param _drawId The drawID to push.\n /// @return The new buffer.\n function push(Buffer memory _buffer, uint32 _drawId) internal pure returns (Buffer memory) {\n require(!isInitialized(_buffer) || _drawId == _buffer.lastDrawId + 1, \"DRB/must-be-contig\");\n\n return\n Buffer({\n lastDrawId: _drawId,\n nextIndex: uint32(RingBufferLib.nextIndex(_buffer.nextIndex, _buffer.cardinality)),\n cardinality: _buffer.cardinality\n });\n }\n\n /// @notice Get draw ring buffer index pointer.\n /// @param _buffer The buffer to get the `nextIndex` from.\n /// @param _drawId The draw id to get the index for.\n /// @return The draw ring buffer index pointer.\n function getIndex(Buffer memory _buffer, uint32 _drawId) internal pure returns (uint32) {\n require(isInitialized(_buffer) && _drawId <= _buffer.lastDrawId, \"DRB/future-draw\");\n\n uint32 indexOffset = _buffer.lastDrawId - _drawId;\n require(indexOffset < _buffer.cardinality, \"DRB/expired-draw\");\n\n uint256 mostRecent = RingBufferLib.newestIndex(_buffer.nextIndex, _buffer.cardinality);\n\n return uint32(RingBufferLib.offset(uint32(mostRecent), indexOffset, _buffer.cardinality));\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./libraries/DrawRingBufferLib.sol\";\nimport \"./interfaces/IPrizeDistributionBuffer.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionBuffer\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionBuffer contract provides historical lookups of PrizeDistribution struct parameters (linked with a Draw ID) via a\n circular ring buffer. Historical PrizeDistribution parameters can be accessed on-chain using a drawId to calculate\n ring buffer storage slot. The PrizeDistribution parameters can be created by manager/owner and existing PrizeDistribution\n parameters can only be updated the owner. When adding a new PrizeDistribution basic sanity checks will be used to\n validate the incoming parameters.\n*/\ncontract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable {\n using DrawRingBufferLib for DrawRingBufferLib.Buffer;\n\n /// @notice The maximum cardinality of the prize distribution ring buffer.\n /// @dev even with daily draws, 256 will give us over 8 months of history.\n uint256 internal constant MAX_CARDINALITY = 256;\n\n /// @notice The ceiling for prize distributions. 1e9 = 100%.\n /// @dev It's fixed point 9 because 1e9 is the largest \"1\" that fits into 2**32\n uint256 internal constant TIERS_CEILING = 1e9;\n\n /// @notice Emitted when the contract is deployed.\n /// @param cardinality The maximum number of records in the buffer before they begin to expire.\n event Deployed(uint8 cardinality);\n\n /// @notice PrizeDistribution ring buffer history.\n IPrizeDistributionBuffer.PrizeDistribution[MAX_CARDINALITY]\n internal prizeDistributionRingBuffer;\n\n /// @notice Ring buffer metadata (nextIndex, lastId, cardinality)\n DrawRingBufferLib.Buffer internal bufferMetadata;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionBuffer\n * @param _owner Address of the PrizeDistributionBuffer owner\n * @param _cardinality Cardinality of the `bufferMetadata`\n */\n constructor(address _owner, uint8 _cardinality) Ownable(_owner) {\n bufferMetadata.cardinality = _cardinality;\n emit Deployed(_cardinality);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getBufferCardinality() external view override returns (uint32) {\n return bufferMetadata.cardinality;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistribution(uint32 _drawId)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return _getPrizeDistribution(bufferMetadata, _drawId);\n }\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution[] memory)\n {\n uint256 drawIdsLength = _drawIds.length;\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n IPrizeDistributionBuffer.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionBuffer.PrizeDistribution[](\n drawIdsLength\n );\n\n for (uint256 i = 0; i < drawIdsLength; i++) {\n _prizeDistributions[i] = _getPrizeDistribution(buffer, _drawIds[i]);\n }\n\n return _prizeDistributions;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistributionCount() external view override returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n if (buffer.lastDrawId == 0) {\n return 0;\n }\n\n uint32 bufferNextIndex = buffer.nextIndex;\n\n // If the buffer is full return the cardinality, else retun the nextIndex\n if (prizeDistributionRingBuffer[bufferNextIndex].matchCardinality != 0) {\n return buffer.cardinality;\n } else {\n return bufferNextIndex;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getNewestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n return (prizeDistributionRingBuffer[buffer.getIndex(buffer.lastDrawId)], buffer.lastDrawId);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getOldestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // if the ring buffer is full, the oldest is at the nextIndex\n prizeDistribution = prizeDistributionRingBuffer[buffer.nextIndex];\n\n // The PrizeDistribution at index 0 IS by default the oldest prizeDistribution.\n if (buffer.lastDrawId == 0) {\n drawId = 0; // return 0 to indicate no prizeDistribution ring buffer history\n } else if (prizeDistribution.bitRangeSize == 0) {\n // IF the next PrizeDistribution.bitRangeSize == 0 the ring buffer HAS NOT looped around so the oldest is the first entry.\n prizeDistribution = prizeDistributionRingBuffer[0];\n drawId = (buffer.lastDrawId + 1) - buffer.nextIndex;\n } else {\n // Calculates the drawId using the ring buffer cardinality\n // Sequential drawIds are gauranteed by DrawRingBufferLib.push()\n drawId = (buffer.lastDrawId + 1) - buffer.cardinality;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyManagerOrOwner returns (bool) {\n return _pushPrizeDistribution(_drawId, _prizeDistribution);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function setPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyOwner returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n uint32 index = buffer.getIndex(_drawId);\n prizeDistributionRingBuffer[index] = _prizeDistribution;\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return _drawId;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Gets the PrizeDistributionBuffer for a drawId\n * @param _buffer DrawRingBufferLib.Buffer\n * @param _drawId drawId\n */\n function _getPrizeDistribution(DrawRingBufferLib.Buffer memory _buffer, uint32 _drawId)\n internal\n view\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return prizeDistributionRingBuffer[_buffer.getIndex(_drawId)];\n }\n\n /**\n * @notice Set newest PrizeDistributionBuffer in ring buffer storage.\n * @param _drawId drawId\n * @param _prizeDistribution PrizeDistributionBuffer struct\n */\n function _pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) internal returns (bool) {\n require(_drawId > 0, \"DrawCalc/draw-id-gt-0\");\n require(_prizeDistribution.matchCardinality > 0, \"DrawCalc/matchCardinality-gt-0\");\n require(\n _prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality,\n \"DrawCalc/bitRangeSize-too-large\"\n );\n\n require(_prizeDistribution.bitRangeSize > 0, \"DrawCalc/bitRangeSize-gt-0\");\n require(_prizeDistribution.maxPicksPerUser > 0, \"DrawCalc/maxPicksPerUser-gt-0\");\n require(_prizeDistribution.expiryDuration > 0, \"DrawCalc/expiryDuration-gt-0\");\n\n // ensure that the sum of the tiers are not gt 100%\n uint256 sumTotalTiers = 0;\n uint256 tiersLength = _prizeDistribution.tiers.length;\n\n for (uint256 index = 0; index < tiersLength; index++) {\n uint256 tier = _prizeDistribution.tiers[index];\n sumTotalTiers += tier;\n }\n\n // Each tier amount stored as uint32 - summed can't exceed 1e9\n require(sumTotalTiers <= TIERS_CEILING, \"DrawCalc/tiers-gt-100%\");\n\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // store the PrizeDistribution in the ring buffer\n prizeDistributionRingBuffer[buffer.nextIndex] = _prizeDistribution;\n\n // update the ring buffer data\n bufferMetadata = buffer.push(_drawId);\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return true;\n }\n}\n" + }, + "contracts/PrizeDistributionSplitter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionSource.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionSplitter\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionSplitter contract allows us to deploy\n a second PrizeDistributionBuffer contract and point contracts that will call this one,\n to the correct PrizeDistributionBuffer contract.\n To do so, we set a `drawId` at which the second PrizeDistributionBuffer contract was deployed,\n when calling the `getPrizeDistributions` function with a `drawId` greater than or equal to the one set,\n we query the second PrizeDistributionBuffer contract, otherwise we query the first.\n */\ncontract PrizeDistributionSplitter is IPrizeDistributionSource {\n /// @notice DrawId at which the split occured\n uint32 public immutable drawId;\n\n /// @notice First PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceBefore;\n\n /// @notice Second PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceAtOrAfter;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when the drawId is set\n * @param drawId The drawId that was set\n */\n event DrawIdSet(uint32 drawId);\n\n /**\n * @notice Emitted when prize distribution sources are set\n * @param prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n event PrizeDistributionSourcesSet(\n IPrizeDistributionSource prizeDistributionSourceBefore,\n IPrizeDistributionSource prizeDistributionSourceAtOrAfter\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionSource\n * @param _drawId DrawId at which the split occured\n * @param _prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param _prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n constructor(\n uint32 _drawId,\n IPrizeDistributionSource _prizeDistributionSourceBefore,\n IPrizeDistributionSource _prizeDistributionSourceAtOrAfter\n ) {\n require(_drawId > 0, \"PrizeDistSplitter/drawId-gt-zero\");\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceBefore));\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceAtOrAfter));\n\n drawId = _drawId;\n prizeDistributionSourceBefore = _prizeDistributionSourceBefore;\n prizeDistributionSourceAtOrAfter = _prizeDistributionSourceAtOrAfter;\n\n emit DrawIdSet(_drawId);\n emit PrizeDistributionSourcesSet(\n _prizeDistributionSourceBefore,\n _prizeDistributionSourceAtOrAfter\n );\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionSource.PrizeDistribution[] memory)\n {\n uint256 _drawIdsLength = _drawIds.length;\n uint32 _drawIdSplit = drawId;\n uint256 _atOrAfterIndex;\n\n for (_atOrAfterIndex; _atOrAfterIndex < _drawIdsLength; _atOrAfterIndex++) {\n if (_drawIds[_atOrAfterIndex] >= _drawIdSplit) {\n break;\n }\n }\n\n uint32[] memory _drawIdsBefore;\n uint32[] memory _drawIdsAtOrAfter;\n\n uint256 _drawIdsAtOrAfterLength = _drawIdsLength - _atOrAfterIndex;\n\n if (_atOrAfterIndex > 0) {\n _drawIdsBefore = new uint32[](_atOrAfterIndex);\n }\n\n if (_drawIdsAtOrAfterLength > 0) {\n _drawIdsAtOrAfter = new uint32[](_drawIdsAtOrAfterLength);\n }\n\n uint32 _previousDrawId;\n\n for (uint256 i; i < _drawIdsLength; i++) {\n uint32 _currentDrawId = _drawIds[i];\n require(_currentDrawId > _previousDrawId, \"PrizeDistSplitter/drawId-asc\");\n\n if (i < _atOrAfterIndex) {\n _drawIdsBefore[i] = _currentDrawId;\n } else {\n _drawIdsAtOrAfter[i - _atOrAfterIndex] = _currentDrawId;\n }\n\n _previousDrawId = _currentDrawId;\n }\n\n if (_drawIdsBefore.length == 0) {\n return prizeDistributionSourceAtOrAfter.getPrizeDistributions(_drawIdsAtOrAfter);\n } else if (_drawIdsAtOrAfter.length == 0) {\n return prizeDistributionSourceBefore.getPrizeDistributions(_drawIdsBefore);\n }\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsBefore = prizeDistributionSourceBefore.getPrizeDistributions(\n _drawIdsBefore\n );\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsAtOrAfter = prizeDistributionSourceAtOrAfter\n .getPrizeDistributions(_drawIdsAtOrAfter);\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionSource.PrizeDistribution[](\n _drawIdsLength\n );\n\n for (uint256 i = 0; i < _drawIdsLength; i++) {\n if (i < _atOrAfterIndex) {\n _prizeDistributions[i] = _prizeDistributionsBefore[i];\n } else {\n _prizeDistributions[i] = _prizeDistributionsAtOrAfter[i - _atOrAfterIndex];\n }\n }\n\n return _prizeDistributions;\n }\n\n /* ============ Require Functions ============ */\n\n /**\n * @notice Require that the given `_prizeDistributionSource` address is not the zero address\n * @param _prizeDistributionSource Address to check\n */\n function _requirePrizeDistNotZeroAddress(address _prizeDistributionSource) internal pure {\n require(_prizeDistributionSource != address(0), \"PrizeDistSplitter/not-zero-addr\");\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol';\n" + }, + "@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/ExtendedSafeCastLib.sol\";\nimport \"./libraries/TwabLib.sol\";\nimport \"./interfaces/ITicket.sol\";\nimport \"./ControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Ticket\n * @author PoolTogether Inc Team\n * @notice The Ticket extends the standard ERC20 and ControlledToken interfaces with time-weighted average balance functionality.\n The average balance held by a user between two timestamps can be calculated, as well as the historic balance. The\n historic total supply is available as well as the average total supply between two timestamps.\n\n A user may \"delegate\" their balance; increasing another user's historic balance while retaining their tokens.\n*/\ncontract Ticket is ControlledToken, ITicket {\n using SafeERC20 for IERC20;\n using ExtendedSafeCastLib for uint256;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _DELEGATE_TYPEHASH =\n keccak256(\"Delegate(address user,address delegate,uint256 nonce,uint256 deadline)\");\n\n /// @notice Record of token holders TWABs for each account.\n mapping(address => TwabLib.Account) internal userTwabs;\n\n /// @notice Record of tickets total supply and ring buff parameters used for observation.\n TwabLib.Account internal totalSupplyTwab;\n\n /// @notice Mapping of delegates. Each address can delegate their ticket power to another.\n mapping(address => address) internal delegates;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _name ERC20 ticket token name.\n * @param _symbol ERC20 ticket token symbol.\n * @param decimals_ ERC20 ticket token decimals.\n * @param _controller ERC20 ticket controller address (ie: Prize Pool address).\n */\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ControlledToken(_name, _symbol, decimals_, _controller) {}\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITicket\n function getAccountDetails(address _user)\n external\n view\n override\n returns (TwabLib.AccountDetails memory)\n {\n return userTwabs[_user].details;\n }\n\n /// @inheritdoc ITicket\n function getTwab(address _user, uint16 _index)\n external\n view\n override\n returns (ObservationLib.Observation memory)\n {\n return userTwabs[_user].twabs[_index];\n }\n\n /// @inheritdoc ITicket\n function getBalanceAt(address _user, uint64 _target) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(\n account.twabs,\n account.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getAverageBalancesBetween(\n address _user,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(userTwabs[_user], _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageTotalSuppliesBetween(\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(totalSupplyTwab, _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageBalanceBetween(\n address _user,\n uint64 _startTime,\n uint64 _endTime\n ) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getBalancesAt(address _user, uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory _balances = new uint256[](length);\n\n TwabLib.Account storage twabContext = userTwabs[_user];\n TwabLib.AccountDetails memory details = twabContext.details;\n\n for (uint256 i = 0; i < length; i++) {\n _balances[i] = TwabLib.getBalanceAt(\n twabContext.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return _balances;\n }\n\n /// @inheritdoc ITicket\n function getTotalSupplyAt(uint64 _target) external view override returns (uint256) {\n return\n TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n totalSupplyTwab.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getTotalSuppliesAt(uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory totalSupplies = new uint256[](length);\n\n TwabLib.AccountDetails memory details = totalSupplyTwab.details;\n\n for (uint256 i = 0; i < length; i++) {\n totalSupplies[i] = TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return totalSupplies;\n }\n\n /// @inheritdoc ITicket\n function delegateOf(address _user) external view override returns (address) {\n return delegates[_user];\n }\n\n /// @inheritdoc ITicket\n function controllerDelegateFor(address _user, address _to) external override onlyController {\n _delegate(_user, _to);\n }\n\n /// @inheritdoc ITicket\n function delegateWithSignature(\n address _user,\n address _newDelegate,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external virtual override {\n require(block.timestamp <= _deadline, \"Ticket/delegate-expired-deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_DELEGATE_TYPEHASH, _user, _newDelegate, _useNonce(_user), _deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, _v, _r, _s);\n require(signer == _user, \"Ticket/delegate-invalid-signature\");\n\n _delegate(_user, _newDelegate);\n }\n\n /// @inheritdoc ITicket\n function delegate(address _to) external virtual override {\n _delegate(msg.sender, _to);\n }\n\n /// @notice Delegates a users chance to another\n /// @param _user The user whose balance should be delegated\n /// @param _to The delegate\n function _delegate(address _user, address _to) internal {\n uint256 balance = balanceOf(_user);\n address currentDelegate = delegates[_user];\n\n if (currentDelegate == _to) {\n return;\n }\n\n delegates[_user] = _to;\n\n _transferTwab(currentDelegate, _to, balance);\n\n emit Delegated(_user, _to);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Retrieves the average balances held by a user for a given time frame.\n * @param _account 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 TwabLib.Account storage _account,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) internal view returns (uint256[] memory) {\n uint256 startTimesLength = _startTimes.length;\n require(startTimesLength == _endTimes.length, \"Ticket/start-end-times-length-match\");\n\n TwabLib.AccountDetails memory accountDetails = _account.details;\n\n uint256[] memory averageBalances = new uint256[](startTimesLength);\n uint32 currentTimestamp = uint32(block.timestamp);\n\n for (uint256 i = 0; i < startTimesLength; i++) {\n averageBalances[i] = TwabLib.getAverageBalanceBetween(\n _account.twabs,\n accountDetails,\n uint32(_startTimes[i]),\n uint32(_endTimes[i]),\n currentTimestamp\n );\n }\n\n return averageBalances;\n }\n\n // @inheritdoc ERC20\n function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal override {\n if (_from == _to) {\n return;\n }\n\n address _fromDelegate;\n if (_from != address(0)) {\n _fromDelegate = delegates[_from];\n }\n\n address _toDelegate;\n if (_to != address(0)) {\n _toDelegate = delegates[_to];\n }\n\n _transferTwab(_fromDelegate, _toDelegate, _amount);\n }\n\n /// @notice Transfers the given TWAB balance from one user to another\n /// @param _from The user to transfer the balance from. May be zero in the event of a mint.\n /// @param _to The user to transfer the balance to. May be zero in the event of a burn.\n /// @param _amount The balance that is being transferred.\n function _transferTwab(address _from, address _to, uint256 _amount) internal {\n // If we are transferring tokens from a delegated account to an undelegated account\n if (_from != address(0)) {\n _decreaseUserTwab(_from, _amount);\n\n if (_to == address(0)) {\n _decreaseTotalSupplyTwab(_amount);\n }\n }\n\n // If we are transferring tokens from an undelegated account to a delegated account\n if (_to != address(0)) {\n _increaseUserTwab(_to, _amount);\n\n if (_from == address(0)) {\n _increaseTotalSupplyTwab(_amount);\n }\n }\n }\n\n /**\n * @notice Increase `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _increaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.increaseBalance(_account, _amount.toUint208(), uint32(block.timestamp));\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /**\n * @notice Decrease `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _decreaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.decreaseBalance(\n _account,\n _amount.toUint208(),\n \"Ticket/twab-burn-lt-balance\",\n uint32(block.timestamp)\n );\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /// @notice Decreases the total supply twab. Should be called anytime a balance moves from delegated to undelegated\n /// @param _amount The amount to decrease the total by\n function _decreaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory tsTwab,\n bool tsIsNew\n ) = TwabLib.decreaseBalance(\n totalSupplyTwab,\n _amount.toUint208(),\n \"Ticket/burn-amount-exceeds-total-supply-twab\",\n uint32(block.timestamp)\n );\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(tsTwab);\n }\n }\n\n /// @notice Increases the total supply twab. Should be called anytime a balance moves from undelegated to delegated\n /// @param _amount The amount to increase the total by\n function _increaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory _totalSupply,\n bool tsIsNew\n ) = TwabLib.increaseBalance(totalSupplyTwab, _amount.toUint208(), uint32(block.timestamp));\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(_totalSupply);\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/Ticket.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/PrizePool.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/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/IPrizePool.sol\";\nimport \"../interfaces/ITicket.sol\";\n\n/**\n * @title PoolTogether V4 PrizePool\n * @author PoolTogether Inc Team\n * @notice Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy.\n Users deposit and withdraw from this contract to participate in Prize Pool.\n Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract.\n Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens\n*/\nabstract contract PrizePool is IPrizePool, Ownable, ReentrancyGuard, IERC721Receiver {\n using SafeCast for uint256;\n using SafeERC20 for IERC20;\n using ERC165Checker for address;\n\n /// @notice Semver Version\n string public constant VERSION = \"4.0.0\";\n\n /// @notice Prize Pool ticket. Can only be set once by calling `setTicket()`.\n ITicket internal ticket;\n\n /// @notice The Prize Strategy that this Prize Pool is bound to.\n address internal prizeStrategy;\n\n /// @notice The total amount of tickets a user can hold.\n uint256 internal balanceCap;\n\n /// @notice The total amount of funds that the prize pool can hold.\n uint256 internal liquidityCap;\n\n /// @notice the The awardable balance\n uint256 internal _currentAwardBalance;\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure caller is the prize-strategy\n modifier onlyPrizeStrategy() {\n require(msg.sender == prizeStrategy, \"PrizePool/only-prizeStrategy\");\n _;\n }\n\n /// @dev Function modifier to ensure the deposit amount does not exceed the liquidity cap (if set)\n modifier canAddLiquidity(uint256 _amount) {\n require(_canAddLiquidity(_amount), \"PrizePool/exceeds-liquidity-cap\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Prize Pool\n /// @param _owner Address of the Prize Pool owner\n constructor(address _owner) Ownable(_owner) ReentrancyGuard() {\n _setLiquidityCap(type(uint256).max);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizePool\n function balance() external override returns (uint256) {\n return _balance();\n }\n\n /// @inheritdoc IPrizePool\n function awardBalance() external view override returns (uint256) {\n return _currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function canAwardExternal(address _externalToken) external view override returns (bool) {\n return _canAwardExternal(_externalToken);\n }\n\n /// @inheritdoc IPrizePool\n function isControlled(ITicket _controlledToken) external view override returns (bool) {\n return _isControlled(_controlledToken);\n }\n\n /// @inheritdoc IPrizePool\n function getAccountedBalance() external view override returns (uint256) {\n return _ticketTotalSupply();\n }\n\n /// @inheritdoc IPrizePool\n function getBalanceCap() external view override returns (uint256) {\n return balanceCap;\n }\n\n /// @inheritdoc IPrizePool\n function getLiquidityCap() external view override returns (uint256) {\n return liquidityCap;\n }\n\n /// @inheritdoc IPrizePool\n function getTicket() external view override returns (ITicket) {\n return ticket;\n }\n\n /// @inheritdoc IPrizePool\n function getPrizeStrategy() external view override returns (address) {\n return prizeStrategy;\n }\n\n /// @inheritdoc IPrizePool\n function getToken() external view override returns (address) {\n return address(_token());\n }\n\n /// @inheritdoc IPrizePool\n function captureAwardBalance() external override nonReentrant returns (uint256) {\n uint256 ticketTotalSupply = _ticketTotalSupply();\n uint256 currentAwardBalance = _currentAwardBalance;\n\n // it's possible for the balance to be slightly less due to rounding errors in the underlying yield source\n uint256 currentBalance = _balance();\n uint256 totalInterest = (currentBalance > ticketTotalSupply)\n ? currentBalance - ticketTotalSupply\n : 0;\n\n uint256 unaccountedPrizeBalance = (totalInterest > currentAwardBalance)\n ? totalInterest - currentAwardBalance\n : 0;\n\n if (unaccountedPrizeBalance > 0) {\n currentAwardBalance = totalInterest;\n _currentAwardBalance = currentAwardBalance;\n\n emit AwardCaptured(unaccountedPrizeBalance);\n }\n\n return currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function depositTo(address _to, uint256 _amount)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function depositToAndDelegate(address _to, uint256 _amount, address _delegate)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n ticket.controllerDelegateFor(msg.sender, _delegate);\n }\n\n /// @notice Transfers tokens in from one user and mints tickets to another\n /// @notice _operator The user to transfer tokens from\n /// @notice _to The user to mint tickets to\n /// @notice _amount The amount to transfer and mint\n function _depositTo(address _operator, address _to, uint256 _amount) internal\n {\n require(_canDeposit(_to, _amount), \"PrizePool/exceeds-balance-cap\");\n\n ITicket _ticket = ticket;\n\n _token().safeTransferFrom(_operator, address(this), _amount);\n\n _mint(_to, _amount, _ticket);\n _supply(_amount);\n\n emit Deposited(_operator, _to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function withdrawFrom(address _from, uint256 _amount)\n external\n override\n nonReentrant\n returns (uint256)\n {\n ITicket _ticket = ticket;\n\n // burn the tickets\n _ticket.controllerBurnFrom(msg.sender, _from, _amount);\n\n // redeem the tickets\n uint256 _redeemed = _redeem(_amount);\n\n _token().safeTransfer(_from, _redeemed);\n\n emit Withdrawal(msg.sender, _from, _ticket, _amount, _redeemed);\n\n return _redeemed;\n }\n\n /// @inheritdoc IPrizePool\n function award(address _to, uint256 _amount) external override onlyPrizeStrategy {\n if (_amount == 0) {\n return;\n }\n\n uint256 currentAwardBalance = _currentAwardBalance;\n\n require(_amount <= currentAwardBalance, \"PrizePool/award-exceeds-avail\");\n\n unchecked {\n _currentAwardBalance = currentAwardBalance - _amount;\n }\n\n ITicket _ticket = ticket;\n\n _mint(_to, _amount, _ticket);\n\n emit Awarded(_to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function transferExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit TransferredExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit AwardedExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC721(\n address _to,\n address _externalToken,\n uint256[] calldata _tokenIds\n ) external override onlyPrizeStrategy {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_tokenIds.length == 0) {\n return;\n }\n\n uint256[] memory _awardedTokenIds = new uint256[](_tokenIds.length); \n bool hasAwardedTokenIds;\n\n for (uint256 i = 0; i < _tokenIds.length; i++) {\n try IERC721(_externalToken).safeTransferFrom(address(this), _to, _tokenIds[i]) {\n hasAwardedTokenIds = true;\n _awardedTokenIds[i] = _tokenIds[i];\n } catch (\n bytes memory error\n ) {\n emit ErrorAwardingExternalERC721(error);\n }\n }\n if (hasAwardedTokenIds) { \n emit AwardedExternalERC721(_to, _externalToken, _awardedTokenIds);\n }\n }\n\n /// @inheritdoc IPrizePool\n function setBalanceCap(uint256 _balanceCap) external override onlyOwner returns (bool) {\n _setBalanceCap(_balanceCap);\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner {\n _setLiquidityCap(_liquidityCap);\n }\n\n /// @inheritdoc IPrizePool\n function setTicket(ITicket _ticket) external override onlyOwner returns (bool) {\n require(address(_ticket) != address(0), \"PrizePool/ticket-not-zero-address\");\n require(address(ticket) == address(0), \"PrizePool/ticket-already-set\");\n\n ticket = _ticket;\n\n emit TicketSet(_ticket);\n\n _setBalanceCap(type(uint256).max);\n\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setPrizeStrategy(address _prizeStrategy) external override onlyOwner {\n _setPrizeStrategy(_prizeStrategy);\n }\n\n /// @inheritdoc IPrizePool\n function compLikeDelegate(ICompLike _compLike, address _to) external override onlyOwner {\n if (_compLike.balanceOf(address(this)) > 0) {\n _compLike.delegate(_to);\n }\n }\n\n /// @inheritdoc IERC721Receiver\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n /* ============ Internal Functions ============ */\n\n /// @notice Transfer out `amount` of `externalToken` to recipient `to`\n /// @dev Only awardable `externalToken` can be transferred out\n /// @param _to Recipient address\n /// @param _externalToken Address of the external asset token being transferred\n /// @param _amount Amount of external assets to be transferred\n /// @return True if transfer is successful\n function _transferOut(\n address _to,\n address _externalToken,\n uint256 _amount\n ) internal returns (bool) {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_amount == 0) {\n return false;\n }\n\n IERC20(_externalToken).safeTransfer(_to, _amount);\n\n return true;\n }\n\n /// @notice Called to mint controlled tokens. Ensures that token listener callbacks are fired.\n /// @param _to The user who is receiving the tokens\n /// @param _amount The amount of tokens they are receiving\n /// @param _controlledToken The token that is going to be minted\n function _mint(\n address _to,\n uint256 _amount,\n ITicket _controlledToken\n ) internal {\n _controlledToken.controllerMint(_to, _amount);\n }\n\n /// @dev Checks if `user` can deposit in the Prize Pool based on the current balance cap.\n /// @param _user Address of the user depositing.\n /// @param _amount The amount of tokens to be deposited into the Prize Pool.\n /// @return True if the Prize Pool can receive the specified `amount` of tokens.\n function _canDeposit(address _user, uint256 _amount) internal view returns (bool) {\n uint256 _balanceCap = balanceCap;\n\n if (_balanceCap == type(uint256).max) return true;\n\n return (ticket.balanceOf(_user) + _amount <= _balanceCap);\n }\n\n /// @dev Checks if the Prize Pool can receive liquidity based on the current cap\n /// @param _amount The amount of liquidity to be added to the Prize Pool\n /// @return True if the Prize Pool can receive the specified amount of liquidity\n function _canAddLiquidity(uint256 _amount) internal view returns (bool) {\n uint256 _liquidityCap = liquidityCap;\n if (_liquidityCap == type(uint256).max) return true;\n return (_ticketTotalSupply() + _amount <= _liquidityCap);\n }\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param _controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function _isControlled(ITicket _controlledToken) internal view returns (bool) {\n return (ticket == _controlledToken);\n }\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @param _balanceCap New balance cap.\n function _setBalanceCap(uint256 _balanceCap) internal {\n balanceCap = _balanceCap;\n emit BalanceCapSet(_balanceCap);\n }\n\n /// @notice Allows the owner to set a liquidity cap for the pool\n /// @param _liquidityCap New liquidity cap\n function _setLiquidityCap(uint256 _liquidityCap) internal {\n liquidityCap = _liquidityCap;\n emit LiquidityCapSet(_liquidityCap);\n }\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy\n function _setPrizeStrategy(address _prizeStrategy) internal {\n require(_prizeStrategy != address(0), \"PrizePool/prizeStrategy-not-zero\");\n\n prizeStrategy = _prizeStrategy;\n\n emit PrizeStrategySet(_prizeStrategy);\n }\n\n /// @notice The current total of tickets.\n /// @return Ticket total supply.\n function _ticketTotalSupply() internal view returns (uint256) {\n return ticket.totalSupply();\n }\n\n /// @dev Gets the current time as represented by the current block\n /// @return The timestamp of the current block\n function _currentTime() internal view virtual returns (uint256) {\n return block.timestamp;\n }\n\n /* ============ Abstract Contract Implementatiton ============ */\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view virtual returns (bool);\n\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token\n function _token() internal view virtual returns (IERC20);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal virtual returns (uint256);\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal virtual;\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal virtual returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface,\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n _supportsERC165Interface(account, type(IERC165).interfaceId) &&\n !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)\n internal\n view\n returns (bool[] memory)\n {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in _interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!_supportsERC165Interface(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n * Interface identification is specified in ERC-165.\n */\n function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);\n if (result.length < 32) return false;\n return success && abi.decode(result, (bool));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"../Ticket.sol\";\n\ncontract TicketHarness is Ticket {\n using SafeCast for uint256;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) Ticket(_name, _symbol, decimals_, _controller) {}\n\n function flashLoan(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _burn(_to, _amount);\n }\n\n function burn(address _from, uint256 _amount) external {\n _burn(_from, _amount);\n }\n\n function mint(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n }\n\n function mintTwice(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _mint(_to, _amount);\n }\n\n /// @dev we need to use a different function name than `transfer`\n /// otherwise it collides with the `transfer` function of the `ERC20` contract\n function transferTo(\n address _sender,\n address _recipient,\n uint256 _amount\n ) external {\n _transfer(_sender, _recipient, _amount);\n }\n\n function getBalanceTx(address _user, uint32 _target) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(account.twabs, account.details, _target, uint32(block.timestamp));\n }\n\n function getAverageBalanceTx(\n address _user,\n uint32 _startTime,\n uint32 _endTime\n ) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/TicketHarness.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@pooltogether/yield-source-interface/contracts/IYieldSource.sol\";\n\nimport \"./PrizePool.sol\";\n\n/**\n * @title PoolTogether V4 YieldSourcePrizePool\n * @author PoolTogether Inc Team\n * @notice The Yield Source Prize Pool uses a yield source contract to generate prizes.\n * Funds that are deposited into the prize pool are then deposited into a yield source. (i.e. Aave, Compound, etc...)\n */\ncontract YieldSourcePrizePool is PrizePool {\n using SafeERC20 for IERC20;\n using Address for address;\n\n /// @notice Address of the yield source.\n IYieldSource public immutable yieldSource;\n\n /// @dev Emitted when yield source prize pool is deployed.\n /// @param yieldSource Address of the yield source.\n event Deployed(address indexed yieldSource);\n\n /// @notice Emitted when stray deposit token balance in this contract is swept\n /// @param amount The amount that was swept\n event Swept(uint256 amount);\n\n /// @notice Deploy the Prize Pool and Yield Service with the required contract connections\n /// @param _owner Address of the Yield Source Prize Pool owner\n /// @param _yieldSource Address of the yield source\n constructor(address _owner, IYieldSource _yieldSource) PrizePool(_owner) {\n require(\n address(_yieldSource) != address(0),\n \"YieldSourcePrizePool/yield-source-not-zero-address\"\n );\n\n yieldSource = _yieldSource;\n\n // A hack to determine whether it's an actual yield source\n (bool succeeded, bytes memory data) = address(_yieldSource).staticcall(\n abi.encodePacked(_yieldSource.depositToken.selector)\n );\n address resultingAddress;\n if (data.length > 0) {\n resultingAddress = abi.decode(data, (address));\n }\n require(succeeded && resultingAddress != address(0), \"YieldSourcePrizePool/invalid-yield-source\");\n\n emit Deployed(address(_yieldSource));\n }\n\n /// @notice Sweeps any stray balance of deposit tokens into the yield source.\n /// @dev This becomes prize money\n function sweep() external nonReentrant onlyOwner {\n uint256 balance = _token().balanceOf(address(this));\n _supply(balance);\n\n emit Swept(balance);\n }\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view override returns (bool) {\n IYieldSource _yieldSource = yieldSource;\n return (\n _externalToken != address(_yieldSource) &&\n _externalToken != _yieldSource.depositToken()\n );\n }\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal override returns (uint256) {\n return yieldSource.balanceOfToken(address(this));\n }\n\n /// @notice Returns the address of the ERC20 asset token used for deposits.\n /// @return Address of the ERC20 asset token.\n function _token() internal view override returns (IERC20) {\n return IERC20(yieldSource.depositToken());\n }\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal override {\n _token().safeIncreaseAllowance(address(yieldSource), _mintAmount);\n yieldSource.supplyTokenTo(_mintAmount, address(this));\n }\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal override returns (uint256) {\n return yieldSource.redeemToken(_redeemAmount);\n }\n}\n" + }, + "@pooltogether/yield-source-interface/contracts/IYieldSource.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.6.0;\n\n/// @title Defines the functions used to interact with a yield source. The Prize Pool inherits this contract.\n/// @notice Prize Pools subclasses need to implement this interface so that yield can be generated.\ninterface IYieldSource {\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token address.\n function depositToken() external view returns (address);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens.\n function balanceOfToken(address addr) external returns (uint256);\n\n /// @notice Supplies tokens to the yield source. Allows assets to be supplied on other user's behalf using the `to` param.\n /// @param amount The amount of asset tokens to be supplied. Denominated in `depositToken()` as above.\n /// @param to The user whose balance will receive the tokens\n function supplyTokenTo(uint256 amount, address to) external;\n\n /// @notice Redeems tokens from the yield source.\n /// @param amount The amount of asset tokens to withdraw. Denominated in `depositToken()` as above.\n /// @return The actual amount of interst bearing tokens that were redeemed.\n function redeemToken(uint256 amount) external returns (uint256);\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IReserve.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ReserveHarness.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ERC20Mintable.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IStrategy.sol';\n" + }, + "contracts/test/TwabRewardsHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../TwabRewards.sol\";\n\ncontract TwabRewardsHarness is TwabRewards {\n constructor(ITicket _ticket) TwabRewards(_ticket) {}\n\n function requireTicket(ITicket _ticket) external view {\n return _requireTicket(_ticket);\n }\n\n function isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n external\n pure\n returns (bool)\n {\n return _isClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n}\n" + }, + "contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total amount of tokens transferred to the reserve.\n * @param withdrawAccumulated Total amount of tokens withdrawn from the reserve.\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 2000 + }, + "evmVersion": "berlin", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From f5dd18fd1d6941c53e3f1a327fa134203e5f313c Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 17:05:43 -0500 Subject: [PATCH 4/7] fix(deployments): redeploy TwabRewards on Avalanche --- deployments/avalanche/TwabRewards.json | 78 +++--- .../45c8f80dfd4edb590489bcbaf8232d24.json | 255 ++++++++++++++++++ 2 files changed, 294 insertions(+), 39 deletions(-) create mode 100644 deployments/avalanche/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json diff --git a/deployments/avalanche/TwabRewards.json b/deployments/avalanche/TwabRewards.json index 09bf5c8..7841275 100644 --- a/deployments/avalanche/TwabRewards.json +++ b/deployments/avalanche/TwabRewards.json @@ -1,5 +1,5 @@ { - "address": "0x46d2f8e4D8Ff3d76cf252D89dD9b422f04123D2c", + "address": "0x01A1F0699356afeB850f5A80226C35A9319CAf74", "abi": [ { "inputs": [ @@ -426,19 +426,19 @@ "type": "function" } ], - "transactionHash": "0xecbbcae762c4ae2cdc83d6d759c29dd6b3839f7768a1ea38416c6c534054f54c", + "transactionHash": "0xf849b1bc2e69c63d5226c77911a7bac2bd1ff6d9cf78e9c2b21181efe82c840e", "receipt": { "to": null, "from": "0x4D40eb12430A57965cEe3015348d490C6156dF20", - "contractAddress": "0x46d2f8e4D8Ff3d76cf252D89dD9b422f04123D2c", - "transactionIndex": 0, - "gasUsed": "1759010", + "contractAddress": "0x01A1F0699356afeB850f5A80226C35A9319CAf74", + "transactionIndex": 4, + "gasUsed": "1777571", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xded0d8b20eda5de8dbf642edfdb41f6a27c1ee8d1764f957063fdc87b2b56126", - "transactionHash": "0xecbbcae762c4ae2cdc83d6d759c29dd6b3839f7768a1ea38416c6c534054f54c", + "blockHash": "0xfd83276621bdfc69e2d0a4cf614cde59adba80d7b2c772f7862edf8e2ac722d7", + "transactionHash": "0xf849b1bc2e69c63d5226c77911a7bac2bd1ff6d9cf78e9c2b21181efe82c840e", "logs": [], - "blockNumber": 10626098, - "cumulativeGasUsed": "1759010", + "blockNumber": 15562831, + "cumulativeGasUsed": "2159090", "status": 1, "byzantium": true }, @@ -446,10 +446,10 @@ "0xB27f379C050f6eD0973A01667458af6eCeBc1d90" ], "numDeployments": 1, - "solcInputHash": "9d2b1510a7a05cdcf74c28c8c70bacde", - "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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 bufffer) 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 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 six month minimum,\\n of historical accurate lookups with current estimates of 1 new block\\n every 15 seconds - the of course contain 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\":\"0xa9cd1103707325d2eaba038d7c0f2b271d934448b8782b82f922653eccb8c90a\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], uint8(index))) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x3700cb7657174461ff5b496bbb3aa481275b6aa692dd62f33e726f1255d39d0b\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611eb56200026e600039600081816101820152818161121a01526113720152611eb56000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", + "solcInputHash": "45c8f80dfd4edb590489bcbaf8232d24", + "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\\n\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x19cf7e6f5b339bb8e553268b1dbafd3e12a00239bc642be87dc363d4832542a8\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002179380380620021798339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611f0b6200026e600039600081816101820152818161127001526113c80152611f0b6000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", "devdoc": { "author": "PoolTogether Inc Team", "details": "This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.", @@ -660,24 +660,24 @@ "storageLayout": { "storage": [ { - "astId": 15925, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12394, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_promotions", "offset": 0, "slot": "0", - "type": "t_mapping(t_uint256,t_struct(Promotion)17216_storage)" + "type": "t_mapping(t_uint256,t_struct(Promotion)13793_storage)" }, { - "astId": 15928, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12397, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_latestPromotionId", "offset": 0, "slot": "1", "type": "t_uint256" }, { - "astId": 15935, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12404, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_claimedEpochs", "offset": 0, "slot": "2", @@ -709,76 +709,76 @@ "numberOfBytes": "32", "value": "t_mapping(t_address,t_uint256)" }, - "t_mapping(t_uint256,t_struct(Promotion)17216_storage)": { + "t_mapping(t_uint256,t_struct(Promotion)13793_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct ITwabRewards.Promotion)", "numberOfBytes": "32", - "value": "t_struct(Promotion)17216_storage" + "value": "t_struct(Promotion)13793_storage" }, - "t_struct(Promotion)17216_storage": { + "t_struct(Promotion)13793_storage": { "encoding": "inplace", "label": "struct ITwabRewards.Promotion", "members": [ { - "astId": 17200, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13777, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "creator", "offset": 0, "slot": "0", "type": "t_address" }, { - "astId": 17202, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13779, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "startTimestamp", "offset": 20, "slot": "0", "type": "t_uint64" }, { - "astId": 17204, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13781, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "numberOfEpochs", "offset": 28, "slot": "0", "type": "t_uint8" }, { - "astId": 17206, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13783, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "epochDuration", "offset": 0, "slot": "1", "type": "t_uint48" }, { - "astId": 17208, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13785, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "createdAt", "offset": 6, "slot": "1", "type": "t_uint48" }, { - "astId": 17211, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13788, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "token", "offset": 12, "slot": "1", "type": "t_contract(IERC20)663" }, { - "astId": 17213, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13790, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "tokensPerEpoch", "offset": 0, "slot": "2", "type": "t_uint256" }, { - "astId": 17215, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13792, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "rewardsUnclaimed", "offset": 0, "slot": "3", diff --git a/deployments/avalanche/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json b/deployments/avalanche/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json new file mode 100644 index 0000000..ebd3212 --- /dev/null +++ b/deployments/avalanche/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json @@ -0,0 +1,255 @@ +{ + "language": "Solidity", + "sources": { + "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n" + }, + "@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" + }, + "contracts/TwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\";\n\nimport \"./interfaces/ITwabRewards.sol\";\n\n/**\n * @title PoolTogether V4 TwabRewards\n * @author PoolTogether Inc Team\n * @notice Contract to distribute rewards to depositors in a pool.\n * This contract supports the creation of several promotions that can run simultaneously.\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\n * @dev This contract supports only one prize pool ticket.\n * @dev This contract does not support the use of fee on transfer tokens.\n */\ncontract TwabRewards is ITwabRewards {\n using SafeERC20 for IERC20;\n\n /* ============ Global Variables ============ */\n\n /// @notice Prize pool ticket for which the promotions are created.\n ITicket public immutable ticket;\n\n /// @notice Period during which the promotion owner can't destroy a promotion.\n uint32 public constant GRACE_PERIOD = 60 days;\n\n /// @notice Settings of each promotion.\n mapping(uint256 => Promotion) internal _promotions;\n\n /**\n * @notice Latest recorded promotion id.\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\n */\n uint256 internal _latestPromotionId;\n\n /**\n * @notice Keeps track of claimed rewards per user.\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\n */\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when a promotion is created.\n * @param promotionId Id of the newly created promotion\n */\n event PromotionCreated(uint256 indexed promotionId);\n\n /**\n * @notice Emitted when a promotion is ended.\n * @param promotionId Id of the promotion being ended\n * @param recipient Address of the recipient that will receive the remaining rewards\n * @param amount Amount of tokens transferred to the recipient\n * @param epochNumber Epoch number at which the promotion ended\n */\n event PromotionEnded(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount,\n uint8 epochNumber\n );\n\n /**\n * @notice Emitted when a promotion is destroyed.\n * @param promotionId Id of the promotion being destroyed\n * @param recipient Address of the recipient that will receive the unclaimed rewards\n * @param amount Amount of tokens transferred to the recipient\n */\n event PromotionDestroyed(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount\n );\n\n /**\n * @notice Emitted when a promotion is extended.\n * @param promotionId Id of the promotion being extended\n * @param numberOfEpochs Number of epochs the promotion has been extended by\n */\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\n\n /**\n * @notice Emitted when rewards have been claimed.\n * @param promotionId Id of the promotion for which epoch rewards were claimed\n * @param epochIds Ids of the epochs being claimed\n * @param user Address of the user for which the rewards were claimed\n * @param amount Amount of tokens transferred to the recipient address\n */\n event RewardsClaimed(\n uint256 indexed promotionId,\n uint8[] epochIds,\n address indexed user,\n uint256 amount\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor of the contract.\n * @param _ticket Prize Pool ticket address for which the promotions will be created\n */\n constructor(ITicket _ticket) {\n _requireTicket(_ticket);\n ticket = _ticket;\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITwabRewards\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external override returns (uint256) {\n require(_tokensPerEpoch > 0, \"TwabRewards/tokens-not-zero\");\n require(_epochDuration > 0, \"TwabRewards/duration-not-zero\");\n _requireNumberOfEpochs(_numberOfEpochs);\n\n uint256 _nextPromotionId = _latestPromotionId + 1;\n _latestPromotionId = _nextPromotionId;\n\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\n\n _promotions[_nextPromotionId] = Promotion({\n creator: msg.sender,\n startTimestamp: _startTimestamp,\n numberOfEpochs: _numberOfEpochs,\n epochDuration: _epochDuration,\n createdAt: uint48(block.timestamp),\n token: _token,\n tokensPerEpoch: _tokensPerEpoch,\n rewardsUnclaimed: _amount\n });\n\n uint256 _beforeBalance = _token.balanceOf(address(this));\n\n _token.safeTransferFrom(msg.sender, address(this), _amount);\n\n uint256 _afterBalance = _token.balanceOf(address(this));\n\n require(_beforeBalance + _amount == _afterBalance, \"TwabRewards/promo-amount-diff\");\n\n emit PromotionCreated(_nextPromotionId);\n\n return _nextPromotionId;\n }\n\n /// @inheritdoc ITwabRewards\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n _requirePromotionActive(_promotion);\n\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\n\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\n\n _promotion.token.safeTransfer(_to, _remainingRewards);\n\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\n uint256 _promotionCreatedAt = _promotion.createdAt;\n\n uint256 _gracePeriodEndTimestamp = (\n _promotionEndTimestamp < _promotionCreatedAt\n ? _promotionCreatedAt\n : _promotionEndTimestamp\n ) + GRACE_PERIOD;\n\n require(block.timestamp >= _gracePeriodEndTimestamp, \"TwabRewards/grace-period-active\");\n\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\n delete _promotions[_promotionId];\n\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\n\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\n external\n override\n returns (bool)\n {\n _requireNumberOfEpochs(_numberOfEpochs);\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionActive(_promotion);\n\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\n\n require(\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\n \"TwabRewards/epochs-over-limit\"\n );\n\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\n\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\n\n _promotions[_promotionId].rewardsUnclaimed += _amount;\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\n\n emit PromotionExtended(_promotionId, _numberOfEpochs);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external override returns (uint256) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _rewardsAmount;\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\n uint256 _epochIdsLength = _epochIds.length;\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n uint8 _epochId = _epochIds[index];\n\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \"TwabRewards/rewards-claimed\");\n\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\n\n _promotion.token.safeTransfer(_user, _rewardsAmount);\n\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\n\n return _rewardsAmount;\n }\n\n /// @inheritdoc ITwabRewards\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\n return _getPromotion(_promotionId);\n }\n\n /// @inheritdoc ITwabRewards\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\n return _getCurrentEpochId(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\n return _getRemainingRewards(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view override returns (uint256[] memory) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _epochIdsLength = _epochIds.length;\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\n _rewardsAmount[index] = 0;\n } else {\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\n }\n }\n\n return _rewardsAmount;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Determine if address passed is actually a ticket.\n * @param _ticket Address to check\n */\n function _requireTicket(ITicket _ticket) internal view {\n require(address(_ticket) != address(0), \"TwabRewards/ticket-not-zero-addr\");\n\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\n abi.encodePacked(_ticket.controller.selector)\n );\n\n require(\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\n \"TwabRewards/invalid-ticket\"\n );\n }\n\n /**\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\n * @param _numberOfEpochs Number of epochs to check\n */\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\n require(_numberOfEpochs > 0, \"TwabRewards/epochs-not-zero\");\n }\n\n /**\n * @notice Determine if a promotion is active.\n * @param _promotion Promotion to check\n */\n function _requirePromotionActive(Promotion memory _promotion) internal view {\n require(\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\n \"TwabRewards/promotion-inactive\"\n );\n }\n\n /**\n * @notice Determine if msg.sender is the promotion creator.\n * @param _promotion Promotion to check\n */\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\n require(msg.sender == _promotion.creator, \"TwabRewards/only-promo-creator\");\n }\n\n /**\n * @notice Get settings for a specific promotion.\n * @dev Will revert if the promotion does not exist.\n * @param _promotionId Promotion id to get settings for\n * @return Promotion settings\n */\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\n Promotion memory _promotion = _promotions[_promotionId];\n require(_promotion.creator != address(0), \"TwabRewards/invalid-promotion\");\n return _promotion;\n }\n\n /**\n * @notice Compute promotion end timestamp.\n * @param _promotion Promotion to compute end timestamp for\n * @return Promotion end timestamp\n */\n function _getPromotionEndTimestamp(Promotion memory _promotion)\n internal\n pure\n returns (uint256)\n {\n unchecked {\n return\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\n }\n }\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @dev We return the current epoch id if the promotion has not ended.\n * If the current timestamp is before the promotion start timestamp, we return 0.\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\n * @param _promotion Promotion to get current epoch for\n * @return Epoch id\n */\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\n uint256 _currentEpochId;\n\n if (block.timestamp > _promotion.startTimestamp) {\n unchecked {\n _currentEpochId =\n (block.timestamp - _promotion.startTimestamp) /\n _promotion.epochDuration;\n }\n }\n\n return _currentEpochId;\n }\n\n /**\n * @notice Get reward amount for a specific user.\n * @dev Rewards can only be calculated once the epoch is over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @param _user User to get reward amount for\n * @param _promotion Promotion from which the epoch is\n * @param _epochId Epoch id to get reward amount for\n * @return Reward amount\n */\n function _calculateRewardAmount(\n address _user,\n Promotion memory _promotion,\n uint8 _epochId\n ) internal view returns (uint256) {\n uint64 _epochDuration = _promotion.epochDuration;\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\n\n require(block.timestamp >= _epochEndTimestamp, \"TwabRewards/epoch-not-over\");\n require(_epochId < _promotion.numberOfEpochs, \"TwabRewards/invalid-epoch-id\");\n\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\n _user,\n _epochStartTimestamp,\n _epochEndTimestamp\n );\n\n if (_averageBalance > 0) {\n uint64[] memory _epochStartTimestamps = new uint64[](1);\n _epochStartTimestamps[0] = _epochStartTimestamp;\n\n uint64[] memory _epochEndTimestamps = new uint64[](1);\n _epochEndTimestamps[0] = _epochEndTimestamp;\n\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\n _epochStartTimestamps,\n _epochEndTimestamps\n )[0];\n\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\n }\n\n return 0;\n }\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\n return 0;\n }\n\n return\n _promotion.tokensPerEpoch *\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\n }\n\n /**\n * @notice Set boolean value for a specific epoch.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0011\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\n We get: 0000 0001 << 2 = 0000 0100\n We then OR the mask with the word to set the value.\n We get: 0110 0011 | 0000 0100 = 0110 0111\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\n * @param _epochId Id of the epoch to set the boolean for\n * @return Tightly packed epoch ids with the newly boolean value set\n */\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (uint256)\n {\n return _userClaimedEpochs | (uint256(1) << _epochId);\n }\n\n /**\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0111\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\n We get: 0110 0111 >> 2 = 0001 1001\n We then get the value of the last bit by masking with 1.\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\n We then return the boolean value true since the last bit is 1.\n * @param _userClaimedEpochs Record of epochs already claimed by the user\n * @param _epochId Epoch id to check\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\n */\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (bool)\n {\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\n }\n}\n" + }, + "@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" + }, + "@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" + }, + "contracts/interfaces/ITwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/**\n * @title PoolTogether V4 ITwabRewards\n * @author PoolTogether Inc Team\n * @notice TwabRewards contract interface.\n */\ninterface ITwabRewards {\n /**\n * @notice Struct to keep track of each promotion's settings.\n * @param creator Addresss of the promotion creator\n * @param startTimestamp Timestamp at which the promotion starts\n * @param numberOfEpochs Number of epochs the promotion will last for\n * @param epochDuration Duration of one epoch in seconds\n * @param createdAt Timestamp at which the promotion was created\n * @param token Address of the token to be distributed as reward\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\n */\n struct Promotion {\n address creator;\n uint64 startTimestamp;\n uint8 numberOfEpochs;\n uint48 epochDuration;\n uint48 createdAt;\n IERC20 token;\n uint256 tokensPerEpoch;\n uint256 rewardsUnclaimed;\n }\n\n /**\n * @notice Creates a new promotion.\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\n * So the first promotion will have id 1, the second 2, etc.\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\n * This scenario could happen if the token supplied is a fee on transfer one.\n * @param _token Address of the token to be distributed\n * @param _startTimestamp Timestamp at which the promotion starts\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\n * @param _epochDuration Duration of one epoch in seconds\n * @param _numberOfEpochs Number of epochs the promotion will last for\n * @return Id of the newly created promotion\n */\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external returns (uint256);\n\n /**\n * @notice End currently active promotion and send promotion tokens back to the creator.\n * @dev Will only send back tokens from the epochs that have not completed.\n * @param _promotionId Promotion id to end\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return true if operation was successful\n */\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\n * @dev Will send back all the tokens that have not been claimed yet by users.\n * @dev This function will revert if the promotion is still active.\n * @dev This function will revert if the grace period is not over yet.\n * @param _promotionId Promotion id to destroy\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return True if operation was successful\n */\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Extend promotion by adding more epochs.\n * @param _promotionId Id of the promotion to extend\n * @param _numberOfEpochs Number of epochs to add\n * @return True if the operation was successful\n */\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\n\n /**\n * @notice Claim rewards for a given promotion and epoch.\n * @dev Rewards can be claimed on behalf of a user.\n * @dev Rewards can only be claimed for a past epoch.\n * @param _user Address of the user to claim rewards for\n * @param _promotionId Id of the promotion to claim rewards for\n * @param _epochIds Epoch ids to claim rewards for\n * @return Total amount of rewards claimed\n */\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external returns (uint256);\n\n /**\n * @notice Get settings for a specific promotion.\n * @param _promotionId Id of the promotion to get settings for\n * @return Promotion settings\n */\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @param _promotionId Id of the promotion to get current epoch for\n * @return Current epoch id of the promotion\n */\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get amount of tokens to be rewarded for a given epoch.\n * @dev Rewards amount can only be retrieved for epochs that are over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @dev Will be 0 if user has already claimed rewards for the epoch.\n * @param _user Address of the user to get amount of rewards for\n * @param _promotionId Id of the promotion from which the epoch is\n * @param _epochIds Epoch ids to get reward amount for\n * @return Amount of tokens per epoch to be rewarded\n */\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view returns (uint256[] memory);\n}\n" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "contracts/PrizeTierHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"./interfaces/IPrizeTierHistory.sol\";\nimport \"./libraries/BinarySearchLib.sol\";\n\n/**\n * @title PoolTogether V4 PrizeTierHistory\n * @author PoolTogether Inc Team\n * @notice The PrizeTierHistory smart contract stores a history of PrizeTier structs linked to \n a range of valid Draw IDs. \n * @dev If the history param has single PrizeTier struct with a \"drawId\" of 1 all subsequent\n Draws will use that PrizeTier struct for PrizeDitribution calculations. The BinarySearchLib\n will find a PrizeTier using a \"atOrBefore\" range search when supplied drawId input parameter.\n */\ncontract PrizeTierHistory is IPrizeTierHistory, Manageable {\n\n // @dev The uint32[] type is extended with a binarySearch(uint32) function.\n using BinarySearchLib for uint32[];\n\n /**\n * @notice Ordered array of Draw IDs\n * @dev The history, with sequentially ordered ids, can be searched using binary search.\n The binary search will find index of a drawId (atOrBefore) using a specific drawId (at).\n When a new Draw ID is added to the history, a corresponding mapping of the ID is \n updated in the prizeTiers mapping.\n */\n uint32[] internal history;\n\n /**\n * @notice Mapping a Draw ID to a PrizeTier struct.\n * @dev The prizeTiers mapping links a Draw ID to a PrizeTier struct.\n The prizeTiers mapping is updated when a new Draw ID is added to the history.\n */\n mapping(uint32 => PrizeTier) internal prizeTiers;\n\n constructor(address owner) Ownable(owner) {}\n\n // @inheritdoc IPrizeTierHistory\n function count() external view override returns (uint256) {\n return history.length;\n }\n \n // @inheritdoc IPrizeTierHistory\n function getOldestDrawId() external view override returns (uint32) {\n return history[0];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getNewestDrawId() external view override returns (uint32) {\n return history[history.length - 1];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTier(uint32 drawId) override external view returns (PrizeTier memory) {\n require(drawId > 0, \"PrizeTierHistory/draw-id-not-zero\");\n return prizeTiers[history.binarySearch(drawId)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierList(uint32[] calldata _drawIds) override external view returns (PrizeTier[] memory) {\n uint256 _length = _drawIds.length; \n PrizeTier[] memory _data = new PrizeTier[](_length);\n for (uint256 index = 0; index < _length; index++) {\n _data[index] = prizeTiers[history.binarySearch(_drawIds[index])];\n }\n return _data;\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierAtIndex(uint256 index) external view override returns (PrizeTier memory) {\n return prizeTiers[uint32(index)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function push(PrizeTier calldata nextPrizeTier) override external onlyManagerOrOwner {\n _push(nextPrizeTier);\n }\n \n // @inheritdoc IPrizeTierHistory\n function popAndPush(PrizeTier calldata newPrizeTier) override external onlyOwner returns (uint32) {\n uint length = history.length;\n require(length > 0, \"PrizeTierHistory/history-empty\");\n require(history[length - 1] == newPrizeTier.drawId, \"PrizeTierHistory/invalid-draw-id\");\n _replace(newPrizeTier);\n return newPrizeTier.drawId;\n }\n\n // @inheritdoc IPrizeTierHistory\n function replace(PrizeTier calldata newPrizeTier) override external onlyOwner {\n _replace(newPrizeTier);\n }\n\n function _push(PrizeTier memory _prizeTier) internal {\n uint32 _length = uint32(history.length);\n if (_length > 0) {\n uint32 _id = history[_length - 1];\n require(\n _prizeTier.drawId > _id,\n \"PrizeTierHistory/non-sequential-id\"\n );\n }\n history.push(_prizeTier.drawId);\n prizeTiers[_length] = _prizeTier;\n emit PrizeTierPushed(_prizeTier.drawId, _prizeTier);\n }\n\n function _replace(PrizeTier calldata _prizeTier) internal {\n uint256 cardinality = history.length;\n require(cardinality > 0, \"PrizeTierHistory/no-prize-tiers\");\n uint32 oldestDrawId = history[0];\n require(_prizeTier.drawId >= oldestDrawId, \"PrizeTierHistory/draw-id-out-of-range\");\n uint32 index = history.binarySearch(_prizeTier.drawId);\n require(history[index] == _prizeTier.drawId, \"PrizeTierHistory/draw-id-must-match\");\n prizeTiers[index] = _prizeTier;\n emit PrizeTierSet(_prizeTier.drawId, _prizeTier);\n }\n}\n" + }, + "contracts/libraries/BinarySearchLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\n\n/**\n * @title PoolTogether V4 BinarySearchLib\n * @author PoolTogether Inc Team\n * @notice BinarySearchLib uses binary search to find a parent contract struct with the drawId parameter\n * @dev The implementing contract must provider access to a struct (i.e. PrizeTier) list with is both\n * sorted and indexed by the drawId field for binary search to work.\n */\nlibrary BinarySearchLib {\n\n /**\n * @notice Find ID in array of ordered IDs using Binary Search.\n * @param _history uin32[] - Array of IDsq\n * @param _drawId uint32 - Draw ID to search for\n * @return uint32 - Index of ID in array\n */\n function binarySearch(uint32[] storage _history, uint32 _drawId) internal view returns (uint32) {\n uint32 index;\n uint32 leftSide = 0;\n uint32 rightSide = uint32(_history.length - 1);\n\n uint32 oldestDrawId = _history[0];\n uint32 newestDrawId = _history[rightSide];\n\n require(_drawId >= oldestDrawId, \"BinarySearchLib/draw-id-out-of-range\");\n if (_drawId >= newestDrawId) return rightSide;\n if (_drawId == oldestDrawId) return leftSide;\n\n while (true) {\n uint32 length = rightSide - leftSide;\n uint32 center = leftSide + (length / 2);\n uint32 centerID = _history[center];\n\n if (centerID == _drawId) {\n index = center;\n break;\n }\n\n if (length <= 1) {\n if(_history[rightSide] <= _drawId) {\n index = rightSide;\n } else {\n index = leftSide;\n }\n break;\n }\n \n if (centerID < _drawId) {\n leftSide = center;\n } else {\n rightSide = center - 1;\n }\n }\n\n return index;\n }\n}\n" + }, + "contracts/test/BinarySearchLibHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"../libraries/BinarySearchLib.sol\";\n\ncontract BinarySearchLibHarness {\n using BinarySearchLib for uint32[];\n uint32[] internal history;\n\n function getIndex(uint32 id) external view returns (uint32)\n {\n return history.binarySearch(id);\n }\n \n function getIndexes(uint32[] calldata ids) external view returns (uint32[] memory)\n {\n uint32[] memory data = new uint32[](ids.length);\n for (uint256 i = 0; i < ids.length; i++) {\n data[i] = history.binarySearch(ids[i]);\n }\n return data;\n }\n\n function set(uint32[] calldata _history) external\n {\n history = _history;\n }\n}\n" + }, + "contracts/PrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./interfaces/IPrizeFlush.sol\";\n\n/**\n * @title PoolTogether V4 PrizeFlush\n * @author PoolTogether Inc Team\n * @notice The PrizeFlush contract helps capture interest from the PrizePool and move collected funds\n to a designated PrizeDistributor contract. When deployed, the destination, reserve and strategy\n addresses are set and used as static parameters during every \"flush\" execution. The parameters can be\n reset by the Owner if necessary.\n */\ncontract PrizeFlush is IPrizeFlush, Manageable {\n /**\n * @notice Destination address for captured interest.\n * @dev Should be set to the PrizeDistributor address.\n */\n address internal destination;\n\n /// @notice Reserve address.\n IReserve internal reserve;\n\n /// @notice Strategy address.\n IStrategy internal strategy;\n\n /**\n * @notice Emitted when contract has been deployed.\n * @param destination Destination address\n * @param reserve Strategy address\n * @param strategy Reserve address\n *\n */\n event Deployed(\n address indexed destination,\n IReserve indexed reserve,\n IStrategy indexed strategy\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy Prize Flush.\n * @param _owner Prize Flush owner address\n * @param _destination Destination address\n * @param _strategy Strategy address\n * @param _reserve Reserve address\n *\n */\n constructor(\n address _owner,\n address _destination,\n IStrategy _strategy,\n IReserve _reserve\n ) Ownable(_owner) {\n _setDestination(_destination);\n _setReserve(_reserve);\n _setStrategy(_strategy);\n\n emit Deployed(_destination, _reserve, _strategy);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeFlush\n function getDestination() external view override returns (address) {\n return destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function getReserve() external view override returns (IReserve) {\n return reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function getStrategy() external view override returns (IStrategy) {\n return strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function setDestination(address _destination) external override onlyOwner returns (address) {\n _setDestination(_destination);\n emit DestinationSet(_destination);\n return _destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function setReserve(IReserve _reserve) external override onlyOwner returns (IReserve) {\n _setReserve(_reserve);\n emit ReserveSet(_reserve);\n return _reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function setStrategy(IStrategy _strategy) external override onlyOwner returns (IStrategy) {\n _setStrategy(_strategy);\n emit StrategySet(_strategy);\n return _strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function flush() external override onlyManagerOrOwner returns (bool) {\n // Captures interest from PrizePool and distributes funds using a PrizeSplitStrategy.\n strategy.distribute();\n\n // After funds are distributed using PrizeSplitStrategy we EXPECT funds to be located in the Reserve.\n IReserve _reserve = reserve;\n IERC20 _token = _reserve.getToken();\n uint256 _amount = _token.balanceOf(address(_reserve));\n\n // IF the tokens were succesfully moved to the Reserve, now move them to the destination (PrizeDistributor) address.\n if (_amount > 0) {\n address _destination = destination;\n\n // Create checkpoint and transfers new total balance to PrizeDistributor\n _reserve.withdrawTo(_destination, _amount);\n\n emit Flushed(_destination, _amount);\n return true;\n }\n\n return false;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Set global destination variable.\n * @dev `_destination` cannot be the zero address.\n * @param _destination Destination address\n */\n function _setDestination(address _destination) internal {\n require(_destination != address(0), \"Flush/destination-not-zero-address\");\n destination = _destination;\n }\n\n /**\n * @notice Set global reserve variable.\n * @dev `_reserve` cannot be the zero address.\n * @param _reserve Reserve address\n */\n function _setReserve(IReserve _reserve) internal {\n require(address(_reserve) != address(0), \"Flush/reserve-not-zero-address\");\n reserve = _reserve;\n }\n\n /**\n * @notice Set global strategy variable.\n * @dev `_strategy` cannot be the zero address.\n * @param _strategy Strategy address\n */\n function _setStrategy(IStrategy _strategy) internal {\n require(address(_strategy) != address(0), \"Flush/strategy-not-zero-address\");\n strategy = _strategy;\n }\n}\n" + }, + "contracts/interfaces/IPrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IReserve.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/IStrategy.sol\";\n\ninterface IPrizeFlush {\n /**\n * @notice Emit when the flush function has executed.\n * @param destination Address receiving funds\n * @param amount Amount of tokens transferred\n */\n event Flushed(address indexed destination, uint256 amount);\n\n /**\n * @notice Emit when destination is set.\n * @param destination Destination address\n */\n event DestinationSet(address destination);\n\n /**\n * @notice Emit when strategy is set.\n * @param strategy Strategy address\n */\n event StrategySet(IStrategy strategy);\n\n /**\n * @notice Emit when reserve is set.\n * @param reserve Reserve address\n */\n event ReserveSet(IReserve reserve);\n\n /// @notice Read global destination variable.\n function getDestination() external view returns (address);\n\n /// @notice Read global reserve variable.\n function getReserve() external view returns (IReserve);\n\n /// @notice Read global strategy variable.\n function getStrategy() external view returns (IStrategy);\n\n /// @notice Set global destination variable.\n function setDestination(address _destination) external returns (address);\n\n /// @notice Set global reserve variable.\n function setReserve(IReserve _reserve) external returns (IReserve);\n\n /// @notice Set global strategy variable.\n function setStrategy(IStrategy _strategy) external returns (IStrategy);\n\n /**\n * @notice Migrate interest from PrizePool to PrizeDistributor in a single transaction.\n * @dev Captures interest, checkpoint data and transfers tokens to final destination.\n * @return True if operation is successful.\n */\n function flush() external returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total depsosited\n * @param withdrawAccumulated Total withdrawn\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./PrizeSplit.sol\";\nimport \"../interfaces/IStrategy.sol\";\nimport \"../interfaces/IPrizePool.sol\";\n\n/**\n * @title PoolTogether V4 PrizeSplitStrategy\n * @author PoolTogether Inc Team\n * @notice Captures PrizePool interest for PrizeReserve and additional PrizeSplit recipients.\n The PrizeSplitStrategy will have at minimum a single PrizeSplit with 100% of the captured\n interest transfered to the PrizeReserve. Additional PrizeSplits can be added, depending on\n the deployers requirements (i.e. percentage to charity). In contrast to previous PoolTogether\n iterations, interest can be captured independent of a new Draw. Ideally (to save gas) interest\n is only captured when also distributing the captured prize(s) to applicable Prize Distributor(s).\n*/\ncontract PrizeSplitStrategy is PrizeSplit, IStrategy {\n /**\n * @notice PrizePool address\n */\n IPrizePool internal immutable prizePool;\n\n /**\n * @notice Deployed Event\n * @param owner Contract owner\n * @param prizePool Linked PrizePool contract\n */\n event Deployed(address indexed owner, IPrizePool prizePool);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy the PrizeSplitStrategy smart contract.\n * @param _owner Owner address\n * @param _prizePool PrizePool address\n */\n constructor(address _owner, IPrizePool _prizePool) Ownable(_owner) {\n require(\n address(_prizePool) != address(0),\n \"PrizeSplitStrategy/prize-pool-not-zero-address\"\n );\n prizePool = _prizePool;\n emit Deployed(_owner, _prizePool);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IStrategy\n function distribute() external override returns (uint256) {\n uint256 prize = prizePool.captureAwardBalance();\n\n if (prize == 0) return 0;\n\n uint256 prizeRemaining = _distributePrizeSplits(prize);\n\n emit Distributed(prize - prizeRemaining);\n\n return prize;\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizePool() external view override returns (IPrizePool) {\n return prizePool;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Award ticket tokens to prize split recipient.\n * @dev Award ticket tokens to prize split recipient via the linked PrizePool contract.\n * @param _to Recipient of minted tokens.\n * @param _amount Amount of minted tokens.\n */\n function _awardPrizeSplitAmount(address _to, uint256 _amount) internal override {\n IControlledToken _ticket = prizePool.getTicket();\n prizePool.award(_to, _amount);\n emit PrizeSplitAwarded(_to, _amount, _ticket);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../interfaces/IPrizeSplit.sol\";\n\n/**\n * @title PrizeSplit Interface\n * @author PoolTogether Inc Team\n */\nabstract contract PrizeSplit is IPrizeSplit, Ownable {\n /* ============ Global Variables ============ */\n PrizeSplitConfig[] internal _prizeSplits;\n\n uint16 public constant ONE_AS_FIXED_POINT_3 = 1000;\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplit(uint256 _prizeSplitIndex)\n external\n view\n override\n returns (PrizeSplitConfig memory)\n {\n return _prizeSplits[_prizeSplitIndex];\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplits() external view override returns (PrizeSplitConfig[] memory) {\n return _prizeSplits;\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplits(PrizeSplitConfig[] calldata _newPrizeSplits)\n external\n override\n onlyOwner\n {\n uint256 newPrizeSplitsLength = _newPrizeSplits.length;\n require(newPrizeSplitsLength <= type(uint8).max, \"PrizeSplit/invalid-prizesplits-length\");\n\n // Add and/or update prize split configs using _newPrizeSplits PrizeSplitConfig structs array.\n for (uint256 index = 0; index < newPrizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _newPrizeSplits[index];\n\n // REVERT when setting the canonical burn address.\n require(split.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // IF the CURRENT prizeSplits length is below the NEW prizeSplits\n // PUSH the PrizeSplit struct to end of the list.\n if (_prizeSplits.length <= index) {\n _prizeSplits.push(split);\n } else {\n // ELSE update an existing PrizeSplit struct with new parameters\n PrizeSplitConfig memory currentSplit = _prizeSplits[index];\n\n // IF new PrizeSplit DOES NOT match the current PrizeSplit\n // WRITE to STORAGE with the new PrizeSplit\n if (\n split.target != currentSplit.target ||\n split.percentage != currentSplit.percentage\n ) {\n _prizeSplits[index] = split;\n } else {\n continue;\n }\n }\n\n // Emit the added/updated prize split config.\n emit PrizeSplitSet(split.target, split.percentage, index);\n }\n\n // Remove old prize splits configs. Match storage _prizesSplits.length with the passed newPrizeSplits.length\n while (_prizeSplits.length > newPrizeSplitsLength) {\n uint256 _index;\n unchecked {\n _index = _prizeSplits.length - 1;\n }\n _prizeSplits.pop();\n emit PrizeSplitRemoved(_index);\n }\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplit(PrizeSplitConfig memory _prizeSplit, uint8 _prizeSplitIndex)\n external\n override\n onlyOwner\n {\n require(_prizeSplitIndex < _prizeSplits.length, \"PrizeSplit/nonexistent-prizesplit\");\n require(_prizeSplit.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // Update the prize split config\n _prizeSplits[_prizeSplitIndex] = _prizeSplit;\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n\n // Emit updated prize split config\n emit PrizeSplitSet(\n _prizeSplit.target,\n _prizeSplit.percentage,\n _prizeSplitIndex\n );\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Calculates total prize split percentage amount.\n * @dev Calculates total PrizeSplitConfig percentage(s) amount. Used to check the total does not exceed 100% of award distribution.\n * @return Total prize split(s) percentage amount\n */\n function _totalPrizeSplitPercentageAmount() internal view returns (uint256) {\n uint256 _tempTotalPercentage;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n _tempTotalPercentage += _prizeSplits[index].percentage;\n }\n\n return _tempTotalPercentage;\n }\n\n /**\n * @notice Distributes prize split(s).\n * @dev Distributes prize split(s) by awarding ticket or sponsorship tokens.\n * @param _prize Starting prize award amount\n * @return The remainder after splits are taken\n */\n function _distributePrizeSplits(uint256 _prize) internal returns (uint256) {\n uint256 _prizeTemp = _prize;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _prizeSplits[index];\n uint256 _splitAmount = (_prize * split.percentage) / 1000;\n\n // Award the prize split distribution amount.\n _awardPrizeSplitAmount(split.target, _splitAmount);\n\n // Update the remaining prize amount after distributing the prize split percentage.\n _prizeTemp -= _splitAmount;\n }\n\n return _prizeTemp;\n }\n\n /**\n * @notice Mints ticket or sponsorship tokens to prize split recipient.\n * @dev Mints ticket or sponsorship tokens to prize split recipient via the linked PrizePool contract.\n * @param _target Recipient of minted tokens\n * @param _amount Amount of minted tokens\n */\n function _awardPrizeSplitAmount(address _target, uint256 _amount) internal virtual;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/ITicket.sol\";\n\ninterface IPrizePool {\n /// @dev Event emitted when controlled token is added\n event ControlledTokenAdded(ITicket indexed token);\n\n event AwardCaptured(uint256 amount);\n\n /// @dev Event emitted when assets are deposited\n event Deposited(\n address indexed operator,\n address indexed to,\n ITicket indexed token,\n uint256 amount\n );\n\n /// @dev Event emitted when interest is awarded to a winner\n event Awarded(address indexed winner, ITicket indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are awarded to a winner\n event AwardedExternalERC20(address indexed winner, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are transferred out\n event TransferredExternalERC20(address indexed to, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC721s are awarded to a winner\n event AwardedExternalERC721(address indexed winner, address indexed token, uint256[] tokenIds);\n\n /// @dev Event emitted when assets are withdrawn\n event Withdrawal(\n address indexed operator,\n address indexed from,\n ITicket indexed token,\n uint256 amount,\n uint256 redeemed\n );\n\n /// @dev Event emitted when the Balance Cap is set\n event BalanceCapSet(uint256 balanceCap);\n\n /// @dev Event emitted when the Liquidity Cap is set\n event LiquidityCapSet(uint256 liquidityCap);\n\n /// @dev Event emitted when the Prize Strategy is set\n event PrizeStrategySet(address indexed prizeStrategy);\n\n /// @dev Event emitted when the Ticket is set\n event TicketSet(ITicket indexed ticket);\n\n /// @dev Emitted when there was an error thrown awarding an External ERC721\n event ErrorAwardingExternalERC721(bytes error);\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n function depositTo(address to, uint256 amount) external;\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens,\n /// then sets the delegate on behalf of the caller.\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n /// @param delegate The address to delegate to for the caller\n function depositToAndDelegate(address to, uint256 amount, address delegate) external;\n\n /// @notice Withdraw assets from the Prize Pool instantly.\n /// @param from The address to redeem tokens from.\n /// @param amount The amount of tokens to redeem for assets.\n /// @return The actual amount withdrawn\n function withdrawFrom(address from, uint256 amount) external returns (uint256);\n\n /// @notice Called by the prize strategy to award prizes.\n /// @dev The amount awarded must be less than the awardBalance()\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of assets to be awarded\n function award(address to, uint256 amount) external;\n\n /// @notice Returns the balance that is available to award.\n /// @dev captureAwardBalance() should be called first\n /// @return The total amount of assets to be awarded for the current prize\n function awardBalance() external view returns (uint256);\n\n /// @notice Captures any available interest as award balance.\n /// @dev This function also captures the reserve fees.\n /// @return The total amount of assets to be awarded for the current prize\n function captureAwardBalance() external returns (uint256);\n\n /// @dev Checks with the Prize Pool if a specific token type may be awarded as an external prize\n /// @param externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function canAwardExternal(address externalToken) external view returns (bool);\n\n // @dev Returns the total underlying balance of all assets. This includes both principal and interest.\n /// @return The underlying balance of assets\n function balance() external returns (uint256);\n\n /**\n * @notice Read internal Ticket accounted balance.\n * @return uint256 accountBalance\n */\n function getAccountedBalance() external view returns (uint256);\n\n /**\n * @notice Read internal balanceCap variable\n */\n function getBalanceCap() external view returns (uint256);\n\n /**\n * @notice Read internal liquidityCap variable\n */\n function getLiquidityCap() external view returns (uint256);\n\n /**\n * @notice Read ticket variable\n */\n function getTicket() external view returns (ITicket);\n\n /**\n * @notice Read token variable\n */\n function getToken() external view returns (address);\n\n /**\n * @notice Read prizeStrategy variable\n */\n function getPrizeStrategy() external view returns (address);\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function isControlled(ITicket controlledToken) external view returns (bool);\n\n /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens\n /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything.\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external asset token being awarded\n /// @param amount The amount of external assets to be awarded\n function transferExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the Prize-Strategy to award external ERC20 prizes\n /// @dev Used to award any arbitrary tokens held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of external assets to be awarded\n /// @param externalToken The address of the external asset token being awarded\n function awardExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the prize strategy to award external ERC721 prizes\n /// @dev Used to award any arbitrary NFTs held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external NFT token being awarded\n /// @param tokenIds An array of NFT Token IDs to be transferred\n function awardExternalERC721(\n address to,\n address externalToken,\n uint256[] calldata tokenIds\n ) external;\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @dev If a user wins, his balance can go over the cap. He will be able to withdraw the excess but not deposit.\n /// @dev Needs to be called after deploying a prize pool to be able to deposit into it.\n /// @param balanceCap New balance cap.\n /// @return True if new balance cap has been successfully set.\n function setBalanceCap(uint256 balanceCap) external returns (bool);\n\n /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold\n /// @param liquidityCap The new liquidity cap for the prize pool\n function setLiquidityCap(uint256 liquidityCap) external;\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy.\n function setPrizeStrategy(address _prizeStrategy) external;\n\n /// @notice Set prize pool ticket.\n /// @param ticket Address of the ticket to set.\n /// @return True if ticket has been successfully set.\n function setTicket(ITicket ticket) external returns (bool);\n\n /// @notice Delegate the votes for a Compound COMP-like token held by the prize pool\n /// @param compLike The COMP-like token held by the prize pool that should be delegated\n /// @param to The address to delegate to\n function compLikeDelegate(ICompLike compLike, address to) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./IControlledToken.sol\";\nimport \"./IPrizePool.sol\";\n\n/**\n * @title Abstract prize split contract for adding unique award distribution to static addresses.\n * @author PoolTogether Inc Team\n */\ninterface IPrizeSplit {\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice The prize split configuration struct.\n * @dev The prize split configuration struct used to award prize splits during distribution.\n * @param target Address of recipient receiving the prize split distribution\n * @param percentage Percentage of prize split using a 0-1000 range for single decimal precision i.e. 125 = 12.5%\n */\n struct PrizeSplitConfig {\n address target;\n uint16 percentage;\n }\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is added or updated.\n * @dev Emitted when a PrizeSplitConfig config is added or updated in setPrizeSplits or setPrizeSplit.\n * @param target Address of prize split recipient\n * @param percentage Percentage of prize split. Must be between 0 and 1000 for single decimal precision\n * @param index Index of prize split in the prizeSplts array\n */\n event PrizeSplitSet(address indexed target, uint16 percentage, uint256 index);\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is removed.\n * @dev Emitted when a PrizeSplitConfig config is removed from the prizeSplits array.\n * @param target Index of a previously active prize split config\n */\n event PrizeSplitRemoved(uint256 indexed target);\n\n /**\n * @notice Read prize split config from active PrizeSplits.\n * @dev Read PrizeSplitConfig struct from prizeSplits array.\n * @param prizeSplitIndex Index position of PrizeSplitConfig\n * @return PrizeSplitConfig Single prize split config\n */\n function getPrizeSplit(uint256 prizeSplitIndex) external view returns (PrizeSplitConfig memory);\n\n /**\n * @notice Read all prize splits configs.\n * @dev Read all PrizeSplitConfig structs stored in prizeSplits.\n * @return Array of PrizeSplitConfig structs\n */\n function getPrizeSplits() external view returns (PrizeSplitConfig[] memory);\n\n /**\n * @notice Get PrizePool address\n * @return IPrizePool\n */\n function getPrizePool() external view returns (IPrizePool);\n\n /**\n * @notice Set and remove prize split(s) configs. Only callable by owner.\n * @dev Set and remove prize split configs by passing a new PrizeSplitConfig structs array. Will remove existing PrizeSplitConfig(s) if passed array length is less than existing prizeSplits length.\n * @param newPrizeSplits Array of PrizeSplitConfig structs\n */\n function setPrizeSplits(PrizeSplitConfig[] calldata newPrizeSplits) external;\n\n /**\n * @notice Updates a previously set prize split config.\n * @dev Updates a prize split config by passing a new PrizeSplitConfig struct and current index position. Limited to contract owner.\n * @param prizeStrategySplit PrizeSplitConfig config struct\n * @param prizeSplitIndex Index position of PrizeSplitConfig to update\n */\n function setPrizeSplit(PrizeSplitConfig memory prizeStrategySplit, uint8 prizeSplitIndex)\n external;\n}\n" + }, + "@pooltogether/v4-core/contracts/external/compound/ICompLike.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ICompLike is IERC20 {\n function getCurrentVotes(address account) external view returns (uint96);\n\n function delegate(address delegate) external;\n}\n" + }, + "contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IControlledToken.sol\";\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/ControlledToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\nimport \"./interfaces/IControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Controlled ERC20 Token\n * @author PoolTogether Inc Team\n * @notice ERC20 Tokens with a controller for minting & burning\n */\ncontract ControlledToken is ERC20Permit, IControlledToken {\n /* ============ Global Variables ============ */\n\n /// @notice Interface to the contract responsible for controlling mint/burn\n address public override immutable controller;\n\n /// @notice ERC20 controlled token decimals.\n uint8 private immutable _decimals;\n\n /* ============ Events ============ */\n\n /// @dev Emitted when contract is deployed\n event Deployed(string name, string symbol, uint8 decimals, address indexed controller);\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure that the caller is the controller contract\n modifier onlyController() {\n require(msg.sender == address(controller), \"ControlledToken/only-controller\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Controlled Token with Token Details and the Controller\n /// @param _name The name of the Token\n /// @param _symbol The symbol for the Token\n /// @param decimals_ The number of decimals for the Token\n /// @param _controller Address of the Controller contract for minting & burning\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ERC20Permit(\"PoolTogether ControlledToken\") ERC20(_name, _symbol) {\n require(address(_controller) != address(0), \"ControlledToken/controller-not-zero-address\");\n controller = _controller;\n\n require(decimals_ > 0, \"ControlledToken/decimals-gt-zero\");\n _decimals = decimals_;\n\n emit Deployed(_name, _symbol, decimals_, _controller);\n }\n\n /* ============ External Functions ============ */\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 function controllerMint(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _mint(_user, _amount);\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 function controllerBurn(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _burn(_user, _amount);\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 function controllerBurnFrom(\n address _operator,\n address _user,\n uint256 _amount\n ) external virtual override onlyController {\n if (_operator != _user) {\n _approve(_user, _operator, allowance(_user, _operator) - _amount);\n }\n\n _burn(_user, _amount);\n }\n\n /// @notice Returns the ERC20 controlled token decimals.\n /// @dev This value should be equal to the decimals of the token used to deposit into the pool.\n /// @return uint8 decimals.\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n\n _afterTokenTransfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s;\n uint8 v;\n assembly {\n s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\n v := add(shr(255, vs), 27)\n }\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/**\n * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},\n * which have permission to mint (create) new tokens as they see fit.\n *\n * At construction, the deployer of the contract is the only minter.\n */\ncontract ERC20Mintable is ERC20 {\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}\n\n /**\n * @dev See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the {MinterRole}.\n */\n function mint(address account, uint256 amount) public {\n _mint(account, amount);\n }\n\n function burn(address account, uint256 amount) public returns (bool) {\n _burn(account, amount);\n return true;\n }\n\n function masterTransfer(\n address from,\n address to,\n uint256 amount\n ) public {\n _transfer(from, to, amount);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../Reserve.sol\";\nimport \"./ERC20Mintable.sol\";\n\ncontract ReserveHarness is Reserve {\n constructor(address _owner, IERC20 _token) Reserve(_owner, _token) {}\n\n function setObservationsAt(ObservationLib.Observation[] calldata observations) external {\n for (uint256 i = 0; i < observations.length; i++) {\n reserveAccumulators[i] = observations[i];\n }\n\n nextIndex = uint24(observations.length);\n cardinality = uint24(observations.length);\n }\n\n function doubleCheckpoint(ERC20Mintable _token, uint256 _amount) external {\n _checkpoint();\n _token.mint(address(this), _amount);\n _checkpoint();\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/Reserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./interfaces/IReserve.sol\";\nimport \"./libraries/ObservationLib.sol\";\nimport \"./libraries/RingBufferLib.sol\";\n\n/**\n * @title PoolTogether V4 Reserve\n * @author PoolTogether Inc Team\n * @notice The Reserve contract provides historical lookups of a token balance increase during a target timerange.\n As the Reserve contract transfers OUT tokens, the withdraw accumulator is increased. When tokens are\n transfered IN new checkpoint *can* be created if checkpoint() is called after transfering tokens.\n By using the reserve and withdraw accumulators to create a new checkpoint, any contract or account\n can lookup the balance increase of the reserve for a target timerange. \n * @dev By calculating the total held tokens in a specific time range, contracts that require knowledge \n of captured interest during a draw period, can easily call into the Reserve and deterministically\n determine the newly aqcuired tokens for that time range. \n */\ncontract Reserve is IReserve, Manageable {\n using SafeERC20 for IERC20;\n\n /// @notice ERC20 token\n IERC20 public immutable token;\n\n /// @notice Total withdraw amount from reserve\n uint224 public withdrawAccumulator;\n uint32 private _gap;\n\n uint24 internal nextIndex;\n uint24 internal cardinality;\n\n /// @notice The maximum number of twab entries\n uint24 internal constant MAX_CARDINALITY = 16777215; // 2**24 - 1\n\n ObservationLib.Observation[MAX_CARDINALITY] internal reserveAccumulators;\n\n /* ============ Events ============ */\n\n event Deployed(IERC20 indexed token);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _owner Owner address\n * @param _token ERC20 address\n */\n constructor(address _owner, IERC20 _token) Ownable(_owner) {\n token = _token;\n emit Deployed(_token);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IReserve\n function checkpoint() external override {\n _checkpoint();\n }\n\n /// @inheritdoc IReserve\n function getToken() external view override returns (IERC20) {\n return token;\n }\n\n /// @inheritdoc IReserve\n function getReserveAccumulatedBetween(uint32 _startTimestamp, uint32 _endTimestamp)\n external\n view\n override\n returns (uint224)\n {\n require(_startTimestamp < _endTimestamp, \"Reserve/start-less-then-end\");\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n\n (uint24 _newestIndex, ObservationLib.Observation memory _newestObservation) = _getNewestObservation(_nextIndex);\n (uint24 _oldestIndex, ObservationLib.Observation memory _oldestObservation) = _getOldestObservation(_nextIndex);\n\n uint224 _start = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _startTimestamp\n );\n\n uint224 _end = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _endTimestamp\n );\n\n return _end - _start;\n }\n\n /// @inheritdoc IReserve\n function withdrawTo(address _recipient, uint256 _amount) external override onlyManagerOrOwner {\n _checkpoint();\n\n withdrawAccumulator += uint224(_amount);\n \n token.safeTransfer(_recipient, _amount);\n\n emit Withdrawn(_recipient, _amount);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Find optimal observation checkpoint using target timestamp\n * @dev Uses binary search if target timestamp is within ring buffer range.\n * @param _newestObservation ObservationLib.Observation\n * @param _oldestObservation ObservationLib.Observation\n * @param _newestIndex The index of the newest observation\n * @param _oldestIndex The index of the oldest observation\n * @param _cardinality RingBuffer Range\n * @param _timestamp Timestamp target\n *\n * @return Optimal reserveAccumlator for timestamp.\n */\n function _getReserveAccumulatedAt(\n ObservationLib.Observation memory _newestObservation,\n ObservationLib.Observation memory _oldestObservation,\n uint24 _newestIndex,\n uint24 _oldestIndex,\n uint24 _cardinality,\n uint32 _timestamp\n ) internal view returns (uint224) {\n uint32 timeNow = uint32(block.timestamp);\n\n // IF empty ring buffer exit early.\n if (_cardinality == 0) return 0;\n\n /**\n * Ring Buffer Search Optimization\n * Before performing binary search on the ring buffer check\n * to see if timestamp is within range of [o T n] by comparing\n * the target timestamp to the oldest/newest observation.timestamps\n * IF the timestamp is out of the ring buffer range avoid starting\n * a binary search, because we can return NULL or oldestObservation.amount\n */\n\n /**\n * IF oldestObservation.timestamp is after timestamp: T[old ]\n * the Reserve did NOT have a balance or the ring buffer\n * no longer contains that timestamp checkpoint.\n */\n if (_oldestObservation.timestamp > _timestamp) {\n return 0;\n }\n\n /**\n * IF newestObservation.timestamp is before timestamp: [ new]T\n * return _newestObservation.amount since observation\n * contains the highest checkpointed reserveAccumulator.\n */\n if (_newestObservation.timestamp <= _timestamp) {\n return _newestObservation.amount;\n }\n\n // IF the timestamp is witin range of ring buffer start/end: [new T old]\n // FIND the closest observation to the left(or exact) of timestamp: [OT ]\n (\n ObservationLib.Observation memory beforeOrAt,\n ObservationLib.Observation memory atOrAfter\n ) = ObservationLib.binarySearch(\n reserveAccumulators,\n _newestIndex,\n _oldestIndex,\n _timestamp,\n _cardinality,\n timeNow\n );\n\n // IF target timestamp is EXACT match for atOrAfter.timestamp observation return amount.\n // NOT having an exact match with atOrAfter means values will contain accumulator value AFTER the searchable range.\n // ELSE return observation.totalDepositedAccumulator closest to LEFT of target timestamp.\n if (atOrAfter.timestamp == _timestamp) {\n return atOrAfter.amount;\n } else {\n return beforeOrAt.amount;\n }\n }\n\n /// @notice Records the currently accrued reserve amount.\n function _checkpoint() internal {\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n uint256 _balanceOfReserve = token.balanceOf(address(this));\n uint224 _withdrawAccumulator = withdrawAccumulator; //sload\n (uint24 newestIndex, ObservationLib.Observation memory newestObservation) = _getNewestObservation(_nextIndex);\n\n /**\n * IF tokens have been deposited into Reserve contract since the last checkpoint\n * create a new Reserve balance checkpoint. The will will update multiple times in a single block.\n */\n if (_balanceOfReserve + _withdrawAccumulator > newestObservation.amount) {\n uint32 nowTime = uint32(block.timestamp);\n\n // checkpointAccumulator = currentBalance + totalWithdraws\n uint224 newReserveAccumulator = uint224(_balanceOfReserve) + _withdrawAccumulator;\n\n // IF newestObservation IS NOT in the current block.\n // CREATE observation in the accumulators ring buffer.\n if (newestObservation.timestamp != nowTime) {\n reserveAccumulators[_nextIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n nextIndex = uint24(RingBufferLib.nextIndex(_nextIndex, MAX_CARDINALITY));\n if (_cardinality < MAX_CARDINALITY) {\n cardinality = _cardinality + 1;\n }\n }\n // ELSE IF newestObservation IS in the current block.\n // UPDATE the checkpoint previously created in block history.\n else {\n reserveAccumulators[newestIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n }\n\n emit Checkpoint(newReserveAccumulator, _withdrawAccumulator);\n }\n }\n\n /// @notice Retrieves the oldest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getOldestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = _nextIndex;\n observation = reserveAccumulators[index];\n\n // If the TWAB is not initialized we go to the beginning of the TWAB circular buffer at index 0\n if (observation.timestamp == 0) {\n index = 0;\n observation = reserveAccumulators[0];\n }\n }\n\n /// @notice Retrieves the newest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getNewestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = uint24(RingBufferLib.newestIndex(_nextIndex, MAX_CARDINALITY));\n observation = reserveAccumulators[index];\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/libraries/DrawRingBufferLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./RingBufferLib.sol\";\n\n/// @title Library for creating and managing a draw ring buffer.\nlibrary DrawRingBufferLib {\n /// @notice Draw buffer struct.\n struct Buffer {\n uint32 lastDrawId;\n uint32 nextIndex;\n uint32 cardinality;\n }\n\n /// @notice Helper function to know if the draw ring buffer has been initialized.\n /// @dev since draws start at 1 and are monotonically increased, we know we are uninitialized if nextIndex = 0 and lastDrawId = 0.\n /// @param _buffer The buffer to check.\n function isInitialized(Buffer memory _buffer) internal pure returns (bool) {\n return !(_buffer.nextIndex == 0 && _buffer.lastDrawId == 0);\n }\n\n /// @notice Push a draw to the buffer.\n /// @param _buffer The buffer to push to.\n /// @param _drawId The drawID to push.\n /// @return The new buffer.\n function push(Buffer memory _buffer, uint32 _drawId) internal pure returns (Buffer memory) {\n require(!isInitialized(_buffer) || _drawId == _buffer.lastDrawId + 1, \"DRB/must-be-contig\");\n\n return\n Buffer({\n lastDrawId: _drawId,\n nextIndex: uint32(RingBufferLib.nextIndex(_buffer.nextIndex, _buffer.cardinality)),\n cardinality: _buffer.cardinality\n });\n }\n\n /// @notice Get draw ring buffer index pointer.\n /// @param _buffer The buffer to get the `nextIndex` from.\n /// @param _drawId The draw id to get the index for.\n /// @return The draw ring buffer index pointer.\n function getIndex(Buffer memory _buffer, uint32 _drawId) internal pure returns (uint32) {\n require(isInitialized(_buffer) && _drawId <= _buffer.lastDrawId, \"DRB/future-draw\");\n\n uint32 indexOffset = _buffer.lastDrawId - _drawId;\n require(indexOffset < _buffer.cardinality, \"DRB/expired-draw\");\n\n uint256 mostRecent = RingBufferLib.newestIndex(_buffer.nextIndex, _buffer.cardinality);\n\n return uint32(RingBufferLib.offset(uint32(mostRecent), indexOffset, _buffer.cardinality));\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./libraries/DrawRingBufferLib.sol\";\nimport \"./interfaces/IPrizeDistributionBuffer.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionBuffer\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionBuffer contract provides historical lookups of PrizeDistribution struct parameters (linked with a Draw ID) via a\n circular ring buffer. Historical PrizeDistribution parameters can be accessed on-chain using a drawId to calculate\n ring buffer storage slot. The PrizeDistribution parameters can be created by manager/owner and existing PrizeDistribution\n parameters can only be updated the owner. When adding a new PrizeDistribution basic sanity checks will be used to\n validate the incoming parameters.\n*/\ncontract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable {\n using DrawRingBufferLib for DrawRingBufferLib.Buffer;\n\n /// @notice The maximum cardinality of the prize distribution ring buffer.\n /// @dev even with daily draws, 256 will give us over 8 months of history.\n uint256 internal constant MAX_CARDINALITY = 256;\n\n /// @notice The ceiling for prize distributions. 1e9 = 100%.\n /// @dev It's fixed point 9 because 1e9 is the largest \"1\" that fits into 2**32\n uint256 internal constant TIERS_CEILING = 1e9;\n\n /// @notice Emitted when the contract is deployed.\n /// @param cardinality The maximum number of records in the buffer before they begin to expire.\n event Deployed(uint8 cardinality);\n\n /// @notice PrizeDistribution ring buffer history.\n IPrizeDistributionBuffer.PrizeDistribution[MAX_CARDINALITY]\n internal prizeDistributionRingBuffer;\n\n /// @notice Ring buffer metadata (nextIndex, lastId, cardinality)\n DrawRingBufferLib.Buffer internal bufferMetadata;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionBuffer\n * @param _owner Address of the PrizeDistributionBuffer owner\n * @param _cardinality Cardinality of the `bufferMetadata`\n */\n constructor(address _owner, uint8 _cardinality) Ownable(_owner) {\n bufferMetadata.cardinality = _cardinality;\n emit Deployed(_cardinality);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getBufferCardinality() external view override returns (uint32) {\n return bufferMetadata.cardinality;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistribution(uint32 _drawId)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return _getPrizeDistribution(bufferMetadata, _drawId);\n }\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution[] memory)\n {\n uint256 drawIdsLength = _drawIds.length;\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n IPrizeDistributionBuffer.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionBuffer.PrizeDistribution[](\n drawIdsLength\n );\n\n for (uint256 i = 0; i < drawIdsLength; i++) {\n _prizeDistributions[i] = _getPrizeDistribution(buffer, _drawIds[i]);\n }\n\n return _prizeDistributions;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistributionCount() external view override returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n if (buffer.lastDrawId == 0) {\n return 0;\n }\n\n uint32 bufferNextIndex = buffer.nextIndex;\n\n // If the buffer is full return the cardinality, else retun the nextIndex\n if (prizeDistributionRingBuffer[bufferNextIndex].matchCardinality != 0) {\n return buffer.cardinality;\n } else {\n return bufferNextIndex;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getNewestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n return (prizeDistributionRingBuffer[buffer.getIndex(buffer.lastDrawId)], buffer.lastDrawId);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getOldestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // if the ring buffer is full, the oldest is at the nextIndex\n prizeDistribution = prizeDistributionRingBuffer[buffer.nextIndex];\n\n // The PrizeDistribution at index 0 IS by default the oldest prizeDistribution.\n if (buffer.lastDrawId == 0) {\n drawId = 0; // return 0 to indicate no prizeDistribution ring buffer history\n } else if (prizeDistribution.bitRangeSize == 0) {\n // IF the next PrizeDistribution.bitRangeSize == 0 the ring buffer HAS NOT looped around so the oldest is the first entry.\n prizeDistribution = prizeDistributionRingBuffer[0];\n drawId = (buffer.lastDrawId + 1) - buffer.nextIndex;\n } else {\n // Calculates the drawId using the ring buffer cardinality\n // Sequential drawIds are gauranteed by DrawRingBufferLib.push()\n drawId = (buffer.lastDrawId + 1) - buffer.cardinality;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyManagerOrOwner returns (bool) {\n return _pushPrizeDistribution(_drawId, _prizeDistribution);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function setPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyOwner returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n uint32 index = buffer.getIndex(_drawId);\n prizeDistributionRingBuffer[index] = _prizeDistribution;\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return _drawId;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Gets the PrizeDistributionBuffer for a drawId\n * @param _buffer DrawRingBufferLib.Buffer\n * @param _drawId drawId\n */\n function _getPrizeDistribution(DrawRingBufferLib.Buffer memory _buffer, uint32 _drawId)\n internal\n view\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return prizeDistributionRingBuffer[_buffer.getIndex(_drawId)];\n }\n\n /**\n * @notice Set newest PrizeDistributionBuffer in ring buffer storage.\n * @param _drawId drawId\n * @param _prizeDistribution PrizeDistributionBuffer struct\n */\n function _pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) internal returns (bool) {\n require(_drawId > 0, \"DrawCalc/draw-id-gt-0\");\n require(_prizeDistribution.matchCardinality > 0, \"DrawCalc/matchCardinality-gt-0\");\n require(\n _prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality,\n \"DrawCalc/bitRangeSize-too-large\"\n );\n\n require(_prizeDistribution.bitRangeSize > 0, \"DrawCalc/bitRangeSize-gt-0\");\n require(_prizeDistribution.maxPicksPerUser > 0, \"DrawCalc/maxPicksPerUser-gt-0\");\n require(_prizeDistribution.expiryDuration > 0, \"DrawCalc/expiryDuration-gt-0\");\n\n // ensure that the sum of the tiers are not gt 100%\n uint256 sumTotalTiers = 0;\n uint256 tiersLength = _prizeDistribution.tiers.length;\n\n for (uint256 index = 0; index < tiersLength; index++) {\n uint256 tier = _prizeDistribution.tiers[index];\n sumTotalTiers += tier;\n }\n\n // Each tier amount stored as uint32 - summed can't exceed 1e9\n require(sumTotalTiers <= TIERS_CEILING, \"DrawCalc/tiers-gt-100%\");\n\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // store the PrizeDistribution in the ring buffer\n prizeDistributionRingBuffer[buffer.nextIndex] = _prizeDistribution;\n\n // update the ring buffer data\n bufferMetadata = buffer.push(_drawId);\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return true;\n }\n}\n" + }, + "contracts/PrizeDistributionSplitter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionSource.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionSplitter\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionSplitter contract allows us to deploy\n a second PrizeDistributionBuffer contract and point contracts that will call this one,\n to the correct PrizeDistributionBuffer contract.\n To do so, we set a `drawId` at which the second PrizeDistributionBuffer contract was deployed,\n when calling the `getPrizeDistributions` function with a `drawId` greater than or equal to the one set,\n we query the second PrizeDistributionBuffer contract, otherwise we query the first.\n */\ncontract PrizeDistributionSplitter is IPrizeDistributionSource {\n /// @notice DrawId at which the split occured\n uint32 public immutable drawId;\n\n /// @notice First PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceBefore;\n\n /// @notice Second PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceAtOrAfter;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when the drawId is set\n * @param drawId The drawId that was set\n */\n event DrawIdSet(uint32 drawId);\n\n /**\n * @notice Emitted when prize distribution sources are set\n * @param prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n event PrizeDistributionSourcesSet(\n IPrizeDistributionSource prizeDistributionSourceBefore,\n IPrizeDistributionSource prizeDistributionSourceAtOrAfter\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionSource\n * @param _drawId DrawId at which the split occured\n * @param _prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param _prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n constructor(\n uint32 _drawId,\n IPrizeDistributionSource _prizeDistributionSourceBefore,\n IPrizeDistributionSource _prizeDistributionSourceAtOrAfter\n ) {\n require(_drawId > 0, \"PrizeDistSplitter/drawId-gt-zero\");\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceBefore));\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceAtOrAfter));\n\n drawId = _drawId;\n prizeDistributionSourceBefore = _prizeDistributionSourceBefore;\n prizeDistributionSourceAtOrAfter = _prizeDistributionSourceAtOrAfter;\n\n emit DrawIdSet(_drawId);\n emit PrizeDistributionSourcesSet(\n _prizeDistributionSourceBefore,\n _prizeDistributionSourceAtOrAfter\n );\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionSource.PrizeDistribution[] memory)\n {\n uint256 _drawIdsLength = _drawIds.length;\n uint32 _drawIdSplit = drawId;\n uint256 _atOrAfterIndex;\n\n for (_atOrAfterIndex; _atOrAfterIndex < _drawIdsLength; _atOrAfterIndex++) {\n if (_drawIds[_atOrAfterIndex] >= _drawIdSplit) {\n break;\n }\n }\n\n uint32[] memory _drawIdsBefore;\n uint32[] memory _drawIdsAtOrAfter;\n\n uint256 _drawIdsAtOrAfterLength = _drawIdsLength - _atOrAfterIndex;\n\n if (_atOrAfterIndex > 0) {\n _drawIdsBefore = new uint32[](_atOrAfterIndex);\n }\n\n if (_drawIdsAtOrAfterLength > 0) {\n _drawIdsAtOrAfter = new uint32[](_drawIdsAtOrAfterLength);\n }\n\n uint32 _previousDrawId;\n\n for (uint256 i; i < _drawIdsLength; i++) {\n uint32 _currentDrawId = _drawIds[i];\n require(_currentDrawId > _previousDrawId, \"PrizeDistSplitter/drawId-asc\");\n\n if (i < _atOrAfterIndex) {\n _drawIdsBefore[i] = _currentDrawId;\n } else {\n _drawIdsAtOrAfter[i - _atOrAfterIndex] = _currentDrawId;\n }\n\n _previousDrawId = _currentDrawId;\n }\n\n if (_drawIdsBefore.length == 0) {\n return prizeDistributionSourceAtOrAfter.getPrizeDistributions(_drawIdsAtOrAfter);\n } else if (_drawIdsAtOrAfter.length == 0) {\n return prizeDistributionSourceBefore.getPrizeDistributions(_drawIdsBefore);\n }\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsBefore = prizeDistributionSourceBefore.getPrizeDistributions(\n _drawIdsBefore\n );\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsAtOrAfter = prizeDistributionSourceAtOrAfter\n .getPrizeDistributions(_drawIdsAtOrAfter);\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionSource.PrizeDistribution[](\n _drawIdsLength\n );\n\n for (uint256 i = 0; i < _drawIdsLength; i++) {\n if (i < _atOrAfterIndex) {\n _prizeDistributions[i] = _prizeDistributionsBefore[i];\n } else {\n _prizeDistributions[i] = _prizeDistributionsAtOrAfter[i - _atOrAfterIndex];\n }\n }\n\n return _prizeDistributions;\n }\n\n /* ============ Require Functions ============ */\n\n /**\n * @notice Require that the given `_prizeDistributionSource` address is not the zero address\n * @param _prizeDistributionSource Address to check\n */\n function _requirePrizeDistNotZeroAddress(address _prizeDistributionSource) internal pure {\n require(_prizeDistributionSource != address(0), \"PrizeDistSplitter/not-zero-addr\");\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol';\n" + }, + "@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/ExtendedSafeCastLib.sol\";\nimport \"./libraries/TwabLib.sol\";\nimport \"./interfaces/ITicket.sol\";\nimport \"./ControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Ticket\n * @author PoolTogether Inc Team\n * @notice The Ticket extends the standard ERC20 and ControlledToken interfaces with time-weighted average balance functionality.\n The average balance held by a user between two timestamps can be calculated, as well as the historic balance. The\n historic total supply is available as well as the average total supply between two timestamps.\n\n A user may \"delegate\" their balance; increasing another user's historic balance while retaining their tokens.\n*/\ncontract Ticket is ControlledToken, ITicket {\n using SafeERC20 for IERC20;\n using ExtendedSafeCastLib for uint256;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _DELEGATE_TYPEHASH =\n keccak256(\"Delegate(address user,address delegate,uint256 nonce,uint256 deadline)\");\n\n /// @notice Record of token holders TWABs for each account.\n mapping(address => TwabLib.Account) internal userTwabs;\n\n /// @notice Record of tickets total supply and ring buff parameters used for observation.\n TwabLib.Account internal totalSupplyTwab;\n\n /// @notice Mapping of delegates. Each address can delegate their ticket power to another.\n mapping(address => address) internal delegates;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _name ERC20 ticket token name.\n * @param _symbol ERC20 ticket token symbol.\n * @param decimals_ ERC20 ticket token decimals.\n * @param _controller ERC20 ticket controller address (ie: Prize Pool address).\n */\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ControlledToken(_name, _symbol, decimals_, _controller) {}\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITicket\n function getAccountDetails(address _user)\n external\n view\n override\n returns (TwabLib.AccountDetails memory)\n {\n return userTwabs[_user].details;\n }\n\n /// @inheritdoc ITicket\n function getTwab(address _user, uint16 _index)\n external\n view\n override\n returns (ObservationLib.Observation memory)\n {\n return userTwabs[_user].twabs[_index];\n }\n\n /// @inheritdoc ITicket\n function getBalanceAt(address _user, uint64 _target) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(\n account.twabs,\n account.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getAverageBalancesBetween(\n address _user,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(userTwabs[_user], _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageTotalSuppliesBetween(\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(totalSupplyTwab, _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageBalanceBetween(\n address _user,\n uint64 _startTime,\n uint64 _endTime\n ) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getBalancesAt(address _user, uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory _balances = new uint256[](length);\n\n TwabLib.Account storage twabContext = userTwabs[_user];\n TwabLib.AccountDetails memory details = twabContext.details;\n\n for (uint256 i = 0; i < length; i++) {\n _balances[i] = TwabLib.getBalanceAt(\n twabContext.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return _balances;\n }\n\n /// @inheritdoc ITicket\n function getTotalSupplyAt(uint64 _target) external view override returns (uint256) {\n return\n TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n totalSupplyTwab.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getTotalSuppliesAt(uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory totalSupplies = new uint256[](length);\n\n TwabLib.AccountDetails memory details = totalSupplyTwab.details;\n\n for (uint256 i = 0; i < length; i++) {\n totalSupplies[i] = TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return totalSupplies;\n }\n\n /// @inheritdoc ITicket\n function delegateOf(address _user) external view override returns (address) {\n return delegates[_user];\n }\n\n /// @inheritdoc ITicket\n function controllerDelegateFor(address _user, address _to) external override onlyController {\n _delegate(_user, _to);\n }\n\n /// @inheritdoc ITicket\n function delegateWithSignature(\n address _user,\n address _newDelegate,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external virtual override {\n require(block.timestamp <= _deadline, \"Ticket/delegate-expired-deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_DELEGATE_TYPEHASH, _user, _newDelegate, _useNonce(_user), _deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, _v, _r, _s);\n require(signer == _user, \"Ticket/delegate-invalid-signature\");\n\n _delegate(_user, _newDelegate);\n }\n\n /// @inheritdoc ITicket\n function delegate(address _to) external virtual override {\n _delegate(msg.sender, _to);\n }\n\n /// @notice Delegates a users chance to another\n /// @param _user The user whose balance should be delegated\n /// @param _to The delegate\n function _delegate(address _user, address _to) internal {\n uint256 balance = balanceOf(_user);\n address currentDelegate = delegates[_user];\n\n if (currentDelegate == _to) {\n return;\n }\n\n delegates[_user] = _to;\n\n _transferTwab(currentDelegate, _to, balance);\n\n emit Delegated(_user, _to);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Retrieves the average balances held by a user for a given time frame.\n * @param _account 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 TwabLib.Account storage _account,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) internal view returns (uint256[] memory) {\n uint256 startTimesLength = _startTimes.length;\n require(startTimesLength == _endTimes.length, \"Ticket/start-end-times-length-match\");\n\n TwabLib.AccountDetails memory accountDetails = _account.details;\n\n uint256[] memory averageBalances = new uint256[](startTimesLength);\n uint32 currentTimestamp = uint32(block.timestamp);\n\n for (uint256 i = 0; i < startTimesLength; i++) {\n averageBalances[i] = TwabLib.getAverageBalanceBetween(\n _account.twabs,\n accountDetails,\n uint32(_startTimes[i]),\n uint32(_endTimes[i]),\n currentTimestamp\n );\n }\n\n return averageBalances;\n }\n\n // @inheritdoc ERC20\n function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal override {\n if (_from == _to) {\n return;\n }\n\n address _fromDelegate;\n if (_from != address(0)) {\n _fromDelegate = delegates[_from];\n }\n\n address _toDelegate;\n if (_to != address(0)) {\n _toDelegate = delegates[_to];\n }\n\n _transferTwab(_fromDelegate, _toDelegate, _amount);\n }\n\n /// @notice Transfers the given TWAB balance from one user to another\n /// @param _from The user to transfer the balance from. May be zero in the event of a mint.\n /// @param _to The user to transfer the balance to. May be zero in the event of a burn.\n /// @param _amount The balance that is being transferred.\n function _transferTwab(address _from, address _to, uint256 _amount) internal {\n // If we are transferring tokens from a delegated account to an undelegated account\n if (_from != address(0)) {\n _decreaseUserTwab(_from, _amount);\n\n if (_to == address(0)) {\n _decreaseTotalSupplyTwab(_amount);\n }\n }\n\n // If we are transferring tokens from an undelegated account to a delegated account\n if (_to != address(0)) {\n _increaseUserTwab(_to, _amount);\n\n if (_from == address(0)) {\n _increaseTotalSupplyTwab(_amount);\n }\n }\n }\n\n /**\n * @notice Increase `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _increaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.increaseBalance(_account, _amount.toUint208(), uint32(block.timestamp));\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /**\n * @notice Decrease `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _decreaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.decreaseBalance(\n _account,\n _amount.toUint208(),\n \"Ticket/twab-burn-lt-balance\",\n uint32(block.timestamp)\n );\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /// @notice Decreases the total supply twab. Should be called anytime a balance moves from delegated to undelegated\n /// @param _amount The amount to decrease the total by\n function _decreaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory tsTwab,\n bool tsIsNew\n ) = TwabLib.decreaseBalance(\n totalSupplyTwab,\n _amount.toUint208(),\n \"Ticket/burn-amount-exceeds-total-supply-twab\",\n uint32(block.timestamp)\n );\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(tsTwab);\n }\n }\n\n /// @notice Increases the total supply twab. Should be called anytime a balance moves from undelegated to delegated\n /// @param _amount The amount to increase the total by\n function _increaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory _totalSupply,\n bool tsIsNew\n ) = TwabLib.increaseBalance(totalSupplyTwab, _amount.toUint208(), uint32(block.timestamp));\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(_totalSupply);\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/Ticket.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/PrizePool.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/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/IPrizePool.sol\";\nimport \"../interfaces/ITicket.sol\";\n\n/**\n * @title PoolTogether V4 PrizePool\n * @author PoolTogether Inc Team\n * @notice Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy.\n Users deposit and withdraw from this contract to participate in Prize Pool.\n Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract.\n Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens\n*/\nabstract contract PrizePool is IPrizePool, Ownable, ReentrancyGuard, IERC721Receiver {\n using SafeCast for uint256;\n using SafeERC20 for IERC20;\n using ERC165Checker for address;\n\n /// @notice Semver Version\n string public constant VERSION = \"4.0.0\";\n\n /// @notice Prize Pool ticket. Can only be set once by calling `setTicket()`.\n ITicket internal ticket;\n\n /// @notice The Prize Strategy that this Prize Pool is bound to.\n address internal prizeStrategy;\n\n /// @notice The total amount of tickets a user can hold.\n uint256 internal balanceCap;\n\n /// @notice The total amount of funds that the prize pool can hold.\n uint256 internal liquidityCap;\n\n /// @notice the The awardable balance\n uint256 internal _currentAwardBalance;\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure caller is the prize-strategy\n modifier onlyPrizeStrategy() {\n require(msg.sender == prizeStrategy, \"PrizePool/only-prizeStrategy\");\n _;\n }\n\n /// @dev Function modifier to ensure the deposit amount does not exceed the liquidity cap (if set)\n modifier canAddLiquidity(uint256 _amount) {\n require(_canAddLiquidity(_amount), \"PrizePool/exceeds-liquidity-cap\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Prize Pool\n /// @param _owner Address of the Prize Pool owner\n constructor(address _owner) Ownable(_owner) ReentrancyGuard() {\n _setLiquidityCap(type(uint256).max);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizePool\n function balance() external override returns (uint256) {\n return _balance();\n }\n\n /// @inheritdoc IPrizePool\n function awardBalance() external view override returns (uint256) {\n return _currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function canAwardExternal(address _externalToken) external view override returns (bool) {\n return _canAwardExternal(_externalToken);\n }\n\n /// @inheritdoc IPrizePool\n function isControlled(ITicket _controlledToken) external view override returns (bool) {\n return _isControlled(_controlledToken);\n }\n\n /// @inheritdoc IPrizePool\n function getAccountedBalance() external view override returns (uint256) {\n return _ticketTotalSupply();\n }\n\n /// @inheritdoc IPrizePool\n function getBalanceCap() external view override returns (uint256) {\n return balanceCap;\n }\n\n /// @inheritdoc IPrizePool\n function getLiquidityCap() external view override returns (uint256) {\n return liquidityCap;\n }\n\n /// @inheritdoc IPrizePool\n function getTicket() external view override returns (ITicket) {\n return ticket;\n }\n\n /// @inheritdoc IPrizePool\n function getPrizeStrategy() external view override returns (address) {\n return prizeStrategy;\n }\n\n /// @inheritdoc IPrizePool\n function getToken() external view override returns (address) {\n return address(_token());\n }\n\n /// @inheritdoc IPrizePool\n function captureAwardBalance() external override nonReentrant returns (uint256) {\n uint256 ticketTotalSupply = _ticketTotalSupply();\n uint256 currentAwardBalance = _currentAwardBalance;\n\n // it's possible for the balance to be slightly less due to rounding errors in the underlying yield source\n uint256 currentBalance = _balance();\n uint256 totalInterest = (currentBalance > ticketTotalSupply)\n ? currentBalance - ticketTotalSupply\n : 0;\n\n uint256 unaccountedPrizeBalance = (totalInterest > currentAwardBalance)\n ? totalInterest - currentAwardBalance\n : 0;\n\n if (unaccountedPrizeBalance > 0) {\n currentAwardBalance = totalInterest;\n _currentAwardBalance = currentAwardBalance;\n\n emit AwardCaptured(unaccountedPrizeBalance);\n }\n\n return currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function depositTo(address _to, uint256 _amount)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function depositToAndDelegate(address _to, uint256 _amount, address _delegate)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n ticket.controllerDelegateFor(msg.sender, _delegate);\n }\n\n /// @notice Transfers tokens in from one user and mints tickets to another\n /// @notice _operator The user to transfer tokens from\n /// @notice _to The user to mint tickets to\n /// @notice _amount The amount to transfer and mint\n function _depositTo(address _operator, address _to, uint256 _amount) internal\n {\n require(_canDeposit(_to, _amount), \"PrizePool/exceeds-balance-cap\");\n\n ITicket _ticket = ticket;\n\n _token().safeTransferFrom(_operator, address(this), _amount);\n\n _mint(_to, _amount, _ticket);\n _supply(_amount);\n\n emit Deposited(_operator, _to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function withdrawFrom(address _from, uint256 _amount)\n external\n override\n nonReentrant\n returns (uint256)\n {\n ITicket _ticket = ticket;\n\n // burn the tickets\n _ticket.controllerBurnFrom(msg.sender, _from, _amount);\n\n // redeem the tickets\n uint256 _redeemed = _redeem(_amount);\n\n _token().safeTransfer(_from, _redeemed);\n\n emit Withdrawal(msg.sender, _from, _ticket, _amount, _redeemed);\n\n return _redeemed;\n }\n\n /// @inheritdoc IPrizePool\n function award(address _to, uint256 _amount) external override onlyPrizeStrategy {\n if (_amount == 0) {\n return;\n }\n\n uint256 currentAwardBalance = _currentAwardBalance;\n\n require(_amount <= currentAwardBalance, \"PrizePool/award-exceeds-avail\");\n\n unchecked {\n _currentAwardBalance = currentAwardBalance - _amount;\n }\n\n ITicket _ticket = ticket;\n\n _mint(_to, _amount, _ticket);\n\n emit Awarded(_to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function transferExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit TransferredExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit AwardedExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC721(\n address _to,\n address _externalToken,\n uint256[] calldata _tokenIds\n ) external override onlyPrizeStrategy {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_tokenIds.length == 0) {\n return;\n }\n\n uint256[] memory _awardedTokenIds = new uint256[](_tokenIds.length); \n bool hasAwardedTokenIds;\n\n for (uint256 i = 0; i < _tokenIds.length; i++) {\n try IERC721(_externalToken).safeTransferFrom(address(this), _to, _tokenIds[i]) {\n hasAwardedTokenIds = true;\n _awardedTokenIds[i] = _tokenIds[i];\n } catch (\n bytes memory error\n ) {\n emit ErrorAwardingExternalERC721(error);\n }\n }\n if (hasAwardedTokenIds) { \n emit AwardedExternalERC721(_to, _externalToken, _awardedTokenIds);\n }\n }\n\n /// @inheritdoc IPrizePool\n function setBalanceCap(uint256 _balanceCap) external override onlyOwner returns (bool) {\n _setBalanceCap(_balanceCap);\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner {\n _setLiquidityCap(_liquidityCap);\n }\n\n /// @inheritdoc IPrizePool\n function setTicket(ITicket _ticket) external override onlyOwner returns (bool) {\n require(address(_ticket) != address(0), \"PrizePool/ticket-not-zero-address\");\n require(address(ticket) == address(0), \"PrizePool/ticket-already-set\");\n\n ticket = _ticket;\n\n emit TicketSet(_ticket);\n\n _setBalanceCap(type(uint256).max);\n\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setPrizeStrategy(address _prizeStrategy) external override onlyOwner {\n _setPrizeStrategy(_prizeStrategy);\n }\n\n /// @inheritdoc IPrizePool\n function compLikeDelegate(ICompLike _compLike, address _to) external override onlyOwner {\n if (_compLike.balanceOf(address(this)) > 0) {\n _compLike.delegate(_to);\n }\n }\n\n /// @inheritdoc IERC721Receiver\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n /* ============ Internal Functions ============ */\n\n /// @notice Transfer out `amount` of `externalToken` to recipient `to`\n /// @dev Only awardable `externalToken` can be transferred out\n /// @param _to Recipient address\n /// @param _externalToken Address of the external asset token being transferred\n /// @param _amount Amount of external assets to be transferred\n /// @return True if transfer is successful\n function _transferOut(\n address _to,\n address _externalToken,\n uint256 _amount\n ) internal returns (bool) {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_amount == 0) {\n return false;\n }\n\n IERC20(_externalToken).safeTransfer(_to, _amount);\n\n return true;\n }\n\n /// @notice Called to mint controlled tokens. Ensures that token listener callbacks are fired.\n /// @param _to The user who is receiving the tokens\n /// @param _amount The amount of tokens they are receiving\n /// @param _controlledToken The token that is going to be minted\n function _mint(\n address _to,\n uint256 _amount,\n ITicket _controlledToken\n ) internal {\n _controlledToken.controllerMint(_to, _amount);\n }\n\n /// @dev Checks if `user` can deposit in the Prize Pool based on the current balance cap.\n /// @param _user Address of the user depositing.\n /// @param _amount The amount of tokens to be deposited into the Prize Pool.\n /// @return True if the Prize Pool can receive the specified `amount` of tokens.\n function _canDeposit(address _user, uint256 _amount) internal view returns (bool) {\n uint256 _balanceCap = balanceCap;\n\n if (_balanceCap == type(uint256).max) return true;\n\n return (ticket.balanceOf(_user) + _amount <= _balanceCap);\n }\n\n /// @dev Checks if the Prize Pool can receive liquidity based on the current cap\n /// @param _amount The amount of liquidity to be added to the Prize Pool\n /// @return True if the Prize Pool can receive the specified amount of liquidity\n function _canAddLiquidity(uint256 _amount) internal view returns (bool) {\n uint256 _liquidityCap = liquidityCap;\n if (_liquidityCap == type(uint256).max) return true;\n return (_ticketTotalSupply() + _amount <= _liquidityCap);\n }\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param _controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function _isControlled(ITicket _controlledToken) internal view returns (bool) {\n return (ticket == _controlledToken);\n }\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @param _balanceCap New balance cap.\n function _setBalanceCap(uint256 _balanceCap) internal {\n balanceCap = _balanceCap;\n emit BalanceCapSet(_balanceCap);\n }\n\n /// @notice Allows the owner to set a liquidity cap for the pool\n /// @param _liquidityCap New liquidity cap\n function _setLiquidityCap(uint256 _liquidityCap) internal {\n liquidityCap = _liquidityCap;\n emit LiquidityCapSet(_liquidityCap);\n }\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy\n function _setPrizeStrategy(address _prizeStrategy) internal {\n require(_prizeStrategy != address(0), \"PrizePool/prizeStrategy-not-zero\");\n\n prizeStrategy = _prizeStrategy;\n\n emit PrizeStrategySet(_prizeStrategy);\n }\n\n /// @notice The current total of tickets.\n /// @return Ticket total supply.\n function _ticketTotalSupply() internal view returns (uint256) {\n return ticket.totalSupply();\n }\n\n /// @dev Gets the current time as represented by the current block\n /// @return The timestamp of the current block\n function _currentTime() internal view virtual returns (uint256) {\n return block.timestamp;\n }\n\n /* ============ Abstract Contract Implementatiton ============ */\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view virtual returns (bool);\n\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token\n function _token() internal view virtual returns (IERC20);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal virtual returns (uint256);\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal virtual;\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal virtual returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface,\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n _supportsERC165Interface(account, type(IERC165).interfaceId) &&\n !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)\n internal\n view\n returns (bool[] memory)\n {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in _interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!_supportsERC165Interface(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n * Interface identification is specified in ERC-165.\n */\n function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);\n if (result.length < 32) return false;\n return success && abi.decode(result, (bool));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"../Ticket.sol\";\n\ncontract TicketHarness is Ticket {\n using SafeCast for uint256;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) Ticket(_name, _symbol, decimals_, _controller) {}\n\n function flashLoan(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _burn(_to, _amount);\n }\n\n function burn(address _from, uint256 _amount) external {\n _burn(_from, _amount);\n }\n\n function mint(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n }\n\n function mintTwice(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _mint(_to, _amount);\n }\n\n /// @dev we need to use a different function name than `transfer`\n /// otherwise it collides with the `transfer` function of the `ERC20` contract\n function transferTo(\n address _sender,\n address _recipient,\n uint256 _amount\n ) external {\n _transfer(_sender, _recipient, _amount);\n }\n\n function getBalanceTx(address _user, uint32 _target) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(account.twabs, account.details, _target, uint32(block.timestamp));\n }\n\n function getAverageBalanceTx(\n address _user,\n uint32 _startTime,\n uint32 _endTime\n ) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/TicketHarness.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@pooltogether/yield-source-interface/contracts/IYieldSource.sol\";\n\nimport \"./PrizePool.sol\";\n\n/**\n * @title PoolTogether V4 YieldSourcePrizePool\n * @author PoolTogether Inc Team\n * @notice The Yield Source Prize Pool uses a yield source contract to generate prizes.\n * Funds that are deposited into the prize pool are then deposited into a yield source. (i.e. Aave, Compound, etc...)\n */\ncontract YieldSourcePrizePool is PrizePool {\n using SafeERC20 for IERC20;\n using Address for address;\n\n /// @notice Address of the yield source.\n IYieldSource public immutable yieldSource;\n\n /// @dev Emitted when yield source prize pool is deployed.\n /// @param yieldSource Address of the yield source.\n event Deployed(address indexed yieldSource);\n\n /// @notice Emitted when stray deposit token balance in this contract is swept\n /// @param amount The amount that was swept\n event Swept(uint256 amount);\n\n /// @notice Deploy the Prize Pool and Yield Service with the required contract connections\n /// @param _owner Address of the Yield Source Prize Pool owner\n /// @param _yieldSource Address of the yield source\n constructor(address _owner, IYieldSource _yieldSource) PrizePool(_owner) {\n require(\n address(_yieldSource) != address(0),\n \"YieldSourcePrizePool/yield-source-not-zero-address\"\n );\n\n yieldSource = _yieldSource;\n\n // A hack to determine whether it's an actual yield source\n (bool succeeded, bytes memory data) = address(_yieldSource).staticcall(\n abi.encodePacked(_yieldSource.depositToken.selector)\n );\n address resultingAddress;\n if (data.length > 0) {\n resultingAddress = abi.decode(data, (address));\n }\n require(succeeded && resultingAddress != address(0), \"YieldSourcePrizePool/invalid-yield-source\");\n\n emit Deployed(address(_yieldSource));\n }\n\n /// @notice Sweeps any stray balance of deposit tokens into the yield source.\n /// @dev This becomes prize money\n function sweep() external nonReentrant onlyOwner {\n uint256 balance = _token().balanceOf(address(this));\n _supply(balance);\n\n emit Swept(balance);\n }\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view override returns (bool) {\n IYieldSource _yieldSource = yieldSource;\n return (\n _externalToken != address(_yieldSource) &&\n _externalToken != _yieldSource.depositToken()\n );\n }\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal override returns (uint256) {\n return yieldSource.balanceOfToken(address(this));\n }\n\n /// @notice Returns the address of the ERC20 asset token used for deposits.\n /// @return Address of the ERC20 asset token.\n function _token() internal view override returns (IERC20) {\n return IERC20(yieldSource.depositToken());\n }\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal override {\n _token().safeIncreaseAllowance(address(yieldSource), _mintAmount);\n yieldSource.supplyTokenTo(_mintAmount, address(this));\n }\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal override returns (uint256) {\n return yieldSource.redeemToken(_redeemAmount);\n }\n}\n" + }, + "@pooltogether/yield-source-interface/contracts/IYieldSource.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.6.0;\n\n/// @title Defines the functions used to interact with a yield source. The Prize Pool inherits this contract.\n/// @notice Prize Pools subclasses need to implement this interface so that yield can be generated.\ninterface IYieldSource {\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token address.\n function depositToken() external view returns (address);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens.\n function balanceOfToken(address addr) external returns (uint256);\n\n /// @notice Supplies tokens to the yield source. Allows assets to be supplied on other user's behalf using the `to` param.\n /// @param amount The amount of asset tokens to be supplied. Denominated in `depositToken()` as above.\n /// @param to The user whose balance will receive the tokens\n function supplyTokenTo(uint256 amount, address to) external;\n\n /// @notice Redeems tokens from the yield source.\n /// @param amount The amount of asset tokens to withdraw. Denominated in `depositToken()` as above.\n /// @return The actual amount of interst bearing tokens that were redeemed.\n function redeemToken(uint256 amount) external returns (uint256);\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IReserve.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ReserveHarness.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ERC20Mintable.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IStrategy.sol';\n" + }, + "contracts/test/TwabRewardsHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../TwabRewards.sol\";\n\ncontract TwabRewardsHarness is TwabRewards {\n constructor(ITicket _ticket) TwabRewards(_ticket) {}\n\n function requireTicket(ITicket _ticket) external view {\n return _requireTicket(_ticket);\n }\n\n function isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n external\n pure\n returns (bool)\n {\n return _isClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n}\n" + }, + "contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total amount of tokens transferred to the reserve.\n * @param withdrawAccumulated Total amount of tokens withdrawn from the reserve.\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 2000 + }, + "evmVersion": "berlin", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From 3c45d1f13ab53c614d0eb7c746052b84daf286f1 Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 17:12:52 -0500 Subject: [PATCH 5/7] fix(deployments): redeploy TwabRewards on Mainnet --- deployments/mainnet/TwabRewards.json | 78 +++--- .../45c8f80dfd4edb590489bcbaf8232d24.json | 255 ++++++++++++++++++ 2 files changed, 294 insertions(+), 39 deletions(-) create mode 100644 deployments/mainnet/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json diff --git a/deployments/mainnet/TwabRewards.json b/deployments/mainnet/TwabRewards.json index 1b3267e..8e31906 100644 --- a/deployments/mainnet/TwabRewards.json +++ b/deployments/mainnet/TwabRewards.json @@ -1,5 +1,5 @@ { - "address": "0x3Cb049Db6d3E100b8b4765Ca051C809adcC17ed1", + "address": "0xe7934EE0c8b877269A5688ee26dd853785212618", "abi": [ { "inputs": [ @@ -426,19 +426,19 @@ "type": "function" } ], - "transactionHash": "0x8d83aa8613533bbcc09fbef61160446059ff3e5c9203b9c57bfbea3df9d9779b", + "transactionHash": "0xe06e5cbf65186086f99b6f0863266fe6f9a5efe2bc43e79944dd8fdfb0727550", "receipt": { "to": null, "from": "0x4D40eb12430A57965cEe3015348d490C6156dF20", - "contractAddress": "0x3Cb049Db6d3E100b8b4765Ca051C809adcC17ed1", - "transactionIndex": 196, - "gasUsed": "1759010", + "contractAddress": "0xe7934EE0c8b877269A5688ee26dd853785212618", + "transactionIndex": 75, + "gasUsed": "1777571", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xa6ecd522ec313cad78ff247a3d2d4b11dbe5d2ea9ee0886163561d07efd8dbd0", - "transactionHash": "0x8d83aa8613533bbcc09fbef61160446059ff3e5c9203b9c57bfbea3df9d9779b", + "blockHash": "0x3806e4eae55ee741a90ed614905d7d548cbe5c0cdb4d5cd0e0fec0793480d8a2", + "transactionHash": "0xe06e5cbf65186086f99b6f0863266fe6f9a5efe2bc43e79944dd8fdfb0727550", "logs": [], - "blockNumber": 14161968, - "cumulativeGasUsed": "27171611", + "blockNumber": 14899617, + "cumulativeGasUsed": "9561650", "status": 1, "byzantium": true }, @@ -446,10 +446,10 @@ "0xdd4d117723C257CEe402285D3aCF218E9A8236E1" ], "numDeployments": 1, - "solcInputHash": "9d2b1510a7a05cdcf74c28c8c70bacde", - "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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 bufffer) 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 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 six month minimum,\\n of historical accurate lookups with current estimates of 1 new block\\n every 15 seconds - the of course contain 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\":\"0xa9cd1103707325d2eaba038d7c0f2b271d934448b8782b82f922653eccb8c90a\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], uint8(index))) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x3700cb7657174461ff5b496bbb3aa481275b6aa692dd62f33e726f1255d39d0b\",\"license\":\"GPL-3.0\"},\"@pooltogether/v4-periphery/contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611eb56200026e600039600081816101820152818161121a01526113720152611eb56000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611a84565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611833565b610386565b6040516100ed9190611b2c565b6100e1610124366004611a54565b6104ae565b61013c610137366004611a22565b6105eb565b6040516100ed9190611c1f565b6100e1610157366004611a54565b61063b565b61016f61016a3660046119a6565b61080b565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a22565b610c42565b61016f6101dd366004611833565b610c55565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a22565b610e00565b600061021f82610e13565b600061022a84610e69565b905061023581610fa9565b60408101516102458160ff611da8565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611cfb565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d42565b90508060008088815260200190815260200160002060030160008282546103239190611cb7565b909155505060a0830151610342906001600160a01b0316333084611020565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610e69565b90508260008167ffffffffffffffff8111156103b1576103b1611e54565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104a25760008881526002602090815260408083206001600160a01b038d16845290915290205460ff82161c6001908116141561044057600082828151811061042f5761042f611e3e565b602002602001018181525050610490565b610471898589898581811061045757610457611e3e565b905060200201602081019061046c9190611ab0565b6110d7565b82828151811061048357610483611e3e565b6020026020010181815250505b8061049a81611df7565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105065760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061051184610e69565b905061051c81611452565b61052581610fa9565b6000610530826114ab565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff85160217905590915061057b836114f7565b60a0840151909150610597906001600160a01b0316868361155b565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261063582610e69565b92915050565b60006001600160a01b0382166106935760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061069e84610e69565b90506106a981611452565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a008284106106f757836106f9565b825b6107039190611cb7565b9050804210156107555760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a08501516107b9906001600160a01b0316888361155b565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f836040516107f591815260200190565b60405180910390a3506001979650505050505050565b600080841161085c5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff16116108b45760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b6108bd82610e13565b600060015460016108ce9190611cb7565b6001819055905060006108e460ff851687611d42565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610ab591906001600160a01b0391909116815260200190565b60206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190611a3b565b9050610b1c6001600160a01b038a16333085611020565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610b7757600080fd5b505afa158015610b8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610baf9190611a3b565b905080610bbc8484611cb7565b14610c095760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b6000610635610c5083610e69565b6114f7565b600080610c6185610e69565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610d4d576000888883818110610ca757610ca7611e3e565b9050602002016020810190610cbc9190611ab0565b9050600160ff821685901c81161415610d175760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d228b87836110d7565b610d2c9086611cb7565b9450600160ff82161b84179350508080610d4590611df7565b915050610c8b565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610d8f908490611d91565b909155505060a0840151610dad906001600160a01b03168a8561155b565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610deb93929190611b9e565b60405180910390a35090979650505050505050565b6000610635610e0e83610e69565b6114ab565b60008160ff1611610e665760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e08301526106355760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526110d19085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115a9565b50505050565b606082015160009065ffffffffffff16816110f560ff851683611d61565b85602001516111049190611ccf565b905060006111128383611ccf565b90508067ffffffffffffffff1642101561116e5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff16106111c75760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b15801561125e57600080fd5b505afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190611a3b565b90508015611442576040805160018082528183019092526000916020808301908036833701905050905083816000815181106112d4576112d4611e3e565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061132657611326611e3e565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113a99086908690600401611b70565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd91908101906118bf565b60008151811061140f5761140f611e3e565b6020026020010151905080848b60c0015161142a9190611d42565b6114349190611d20565b97505050505050505061144b565b60009450505050505b9392505050565b80516001600160a01b03163314610e665760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561063557826060015165ffffffffffff16836020015167ffffffffffffffff164203816114ef576114ef611e28565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561153157506000919050565b61153a826114ab565b826040015160ff1661154c9190611d91565b8260c001516106359190611d42565b6040516001600160a01b0383166024820152604481018290526115a49084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106d565b505050565b60006115fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661168e9092919063ffffffff16565b8051909150156115a4578080602001905181019061161c9190611984565b6115a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b606061169d84846000856116a5565b949350505050565b60608247101561171d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b61176b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117879190611b10565b60006040518083038185875af1925050503d80600081146117c4576040519150601f19603f3d011682016040523d82523d6000602084013e6117c9565b606091505b50915091506117d98282866117e4565b979650505050505050565b606083156117f357508161144b565b8251156118035782518084602001fd5b8160405162461bcd60e51b81526004016102969190611bec565b803560ff8116811461182e57600080fd5b919050565b6000806000806060858703121561184957600080fd5b843561185481611e6a565b935060208501359250604085013567ffffffffffffffff8082111561187857600080fd5b818701915087601f83011261188c57600080fd5b81358181111561189b57600080fd5b8860208260051b85010111156118b057600080fd5b95989497505060200194505050565b600060208083850312156118d257600080fd5b825167ffffffffffffffff808211156118ea57600080fd5b818501915085601f8301126118fe57600080fd5b81518181111561191057611910611e54565b8060051b604051601f19603f8301168101818110858211171561193557611935611e54565b604052828152858101935084860182860187018a101561195457600080fd5b600095505b83861015611977578051855260019590950194938601938601611959565b5098975050505050505050565b60006020828403121561199657600080fd5b8151801515811461144b57600080fd5b600080600080600060a086880312156119be57600080fd5b85356119c981611e6a565b9450602086013567ffffffffffffffff811681146119e657600080fd5b935060408601359250606086013565ffffffffffff81168114611a0857600080fd5b9150611a166080870161181d565b90509295509295909350565b600060208284031215611a3457600080fd5b5035919050565b600060208284031215611a4d57600080fd5b5051919050565b60008060408385031215611a6757600080fd5b823591506020830135611a7981611e6a565b809150509250929050565b60008060408385031215611a9757600080fd5b82359150611aa76020840161181d565b90509250929050565b600060208284031215611ac257600080fd5b61144b8261181d565b600081518084526020808501945080840160005b83811015611b0557815167ffffffffffffffff1687529582019590820190600101611adf565b509495945050505050565b60008251611b22818460208701611dcb565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611b6457835183529284019291840191600101611b48565b50909695505050505050565b604081526000611b836040830185611acb565b8281036020840152611b958185611acb565b95945050505050565b6040808252810183905260008460608301825b86811015611bd95760ff611bc48461181d565b16825260209283019290910190600101611bb1565b5060209390930193909352509392505050565b6020815260008251806020840152611c0b816040850160208701611dcb565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611c81608084018265ffffffffffff169052565b5060a0830151611c9c60a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611cca57611cca611e12565b500190565b600067ffffffffffffffff808316818516808303821115611cf257611cf2611e12565b01949350505050565b600060ff821660ff84168060ff03821115611d1857611d18611e12565b019392505050565b600082611d3d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d5c57611d5c611e12565b500290565b600067ffffffffffffffff80831681851681830481118215151615611d8857611d88611e12565b02949350505050565b600082821015611da357611da3611e12565b500390565b600060ff821660ff841680821015611dc257611dc2611e12565b90039392505050565b60005b83811015611de6578181015183820152602001611dce565b838111156110d15750506000910152565b6000600019821415611e0b57611e0b611e12565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e6657600080fdfea264697066735822122093aebe8126842f77adfcf2f93bf5a68a510897332a4a90f97601a16656e11e6a64736f6c63430008060033", + "solcInputHash": "45c8f80dfd4edb590489bcbaf8232d24", + "metadata": "{\"compiler\":{\"version\":\"0.8.6+commit.11564f7e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"_ticket\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"}],\"name\":\"PromotionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"PromotionDestroyed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"epochNumber\",\"type\":\"uint8\"}],\"name\":\"PromotionEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"numberOfEpochs\",\"type\":\"uint256\"}],\"name\":\"PromotionExtended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"promotionId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8[]\",\"name\":\"epochIds\",\"type\":\"uint8[]\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardsClaimed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"_tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"createPromotion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"destroyPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"endPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_numberOfEpochs\",\"type\":\"uint8\"}],\"name\":\"extendPromotion\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getCurrentEpochId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getPromotion\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"startTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"uint8\",\"name\":\"numberOfEpochs\",\"type\":\"uint8\"},{\"internalType\":\"uint48\",\"name\":\"epochDuration\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"createdAt\",\"type\":\"uint48\"},{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokensPerEpoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardsUnclaimed\",\"type\":\"uint256\"}],\"internalType\":\"struct ITwabRewards.Promotion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"}],\"name\":\"getRemainingRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_promotionId\",\"type\":\"uint256\"},{\"internalType\":\"uint8[]\",\"name\":\"_epochIds\",\"type\":\"uint8[]\"}],\"name\":\"getRewardsAmount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ticket\",\"outputs\":[{\"internalType\":\"contract ITicket\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"PoolTogether Inc Team\",\"details\":\"This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.\",\"events\":{\"PromotionCreated(uint256)\":{\"params\":{\"promotionId\":\"Id of the newly created promotion\"}},\"PromotionDestroyed(uint256,address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"promotionId\":\"Id of the promotion being destroyed\",\"recipient\":\"Address of the recipient that will receive the unclaimed rewards\"}},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient\",\"epochNumber\":\"Epoch number at which the promotion ended\",\"promotionId\":\"Id of the promotion being ended\",\"recipient\":\"Address of the recipient that will receive the remaining rewards\"}},\"PromotionExtended(uint256,uint256)\":{\"params\":{\"numberOfEpochs\":\"Number of epochs the promotion has been extended by\",\"promotionId\":\"Id of the promotion being extended\"}},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"params\":{\"amount\":\"Amount of tokens transferred to the recipient address\",\"epochIds\":\"Ids of the epochs being claimed\",\"promotionId\":\"Id of the promotion for which epoch rewards were claimed\",\"user\":\"Address of the user for which the rewards were claimed\"}}},\"kind\":\"dev\",\"methods\":{\"claimRewards(address,uint256,uint8[])\":{\"details\":\"Rewards can be claimed on behalf of a user.Rewards can only be claimed for a past epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to claim rewards for\",\"_promotionId\":\"Id of the promotion to claim rewards for\",\"_user\":\"Address of the user to claim rewards for\"},\"returns\":{\"_0\":\"Total amount of rewards claimed\"}},\"constructor\":{\"params\":{\"_ticket\":\"Prize Pool ticket address for which the promotions will be created\"}},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"details\":\"For sake of simplicity, `msg.sender` will be the creator of the promotion.`_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`. This scenario could happen if the token supplied is a fee on transfer one.\",\"params\":{\"_epochDuration\":\"Duration of one epoch in seconds\",\"_numberOfEpochs\":\"Number of epochs the promotion will last for\",\"_startTimestamp\":\"Timestamp at which the promotion starts\",\"_token\":\"Address of the token to be distributed\",\"_tokensPerEpoch\":\"Number of tokens to be distributed per epoch\"},\"returns\":{\"_0\":\"Id of the newly created promotion\"}},\"destroyPromotion(uint256,address)\":{\"details\":\"Will send back all the tokens that have not been claimed yet by users.This function will revert if the promotion is still active.This function will revert if the grace period is not over yet.\",\"params\":{\"_promotionId\":\"Promotion id to destroy\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"True if operation was successful\"}},\"endPromotion(uint256,address)\":{\"details\":\"Will only send back tokens from the epochs that have not completed.\",\"params\":{\"_promotionId\":\"Promotion id to end\",\"_to\":\"Address that will receive the remaining tokens if there are any left\"},\"returns\":{\"_0\":\"true if operation was successful\"}},\"extendPromotion(uint256,uint8)\":{\"params\":{\"_numberOfEpochs\":\"Number of epochs to add\",\"_promotionId\":\"Id of the promotion to extend\"},\"returns\":{\"_0\":\"True if the operation was successful\"}},\"getCurrentEpochId(uint256)\":{\"details\":\"Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\",\"params\":{\"_promotionId\":\"Id of the promotion to get current epoch for\"},\"returns\":{\"_0\":\"Current epoch id of the promotion\"}},\"getPromotion(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get settings for\"},\"returns\":{\"_0\":\"Promotion settings\"}},\"getRemainingRewards(uint256)\":{\"params\":{\"_promotionId\":\"Id of the promotion to get the total amount of tokens left to be rewarded for\"},\"returns\":{\"_0\":\"Amount of tokens left to be rewarded\"}},\"getRewardsAmount(address,uint256,uint8[])\":{\"details\":\"Rewards amount can only be retrieved for epochs that are over.Will revert if `_epochId` is over the total number of epochs or if epoch is not over.Will return 0 if the user average balance of tickets is 0.Will be 0 if user has already claimed rewards for the epoch.\",\"params\":{\"_epochIds\":\"Epoch ids to get reward amount for\",\"_promotionId\":\"Id of the promotion from which the epoch is\",\"_user\":\"Address of the user to get amount of rewards for\"},\"returns\":{\"_0\":\"Amount of tokens per epoch to be rewarded\"}}},\"stateVariables\":{\"_claimedEpochs\":{\"details\":\"_claimedEpochs[promotionId][user] => claimedEpochsWe pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\"},\"_latestPromotionId\":{\"details\":\"Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\"}},\"title\":\"PoolTogether V4 TwabRewards\",\"version\":1},\"userdoc\":{\"events\":{\"PromotionCreated(uint256)\":{\"notice\":\"Emitted when a promotion is created.\"},\"PromotionDestroyed(uint256,address,uint256)\":{\"notice\":\"Emitted when a promotion is destroyed.\"},\"PromotionEnded(uint256,address,uint256,uint8)\":{\"notice\":\"Emitted when a promotion is ended.\"},\"PromotionExtended(uint256,uint256)\":{\"notice\":\"Emitted when a promotion is extended.\"},\"RewardsClaimed(uint256,uint8[],address,uint256)\":{\"notice\":\"Emitted when rewards have been claimed.\"}},\"kind\":\"user\",\"methods\":{\"GRACE_PERIOD()\":{\"notice\":\"Period during which the promotion owner can't destroy a promotion.\"},\"claimRewards(address,uint256,uint8[])\":{\"notice\":\"Claim rewards for a given promotion and epoch.\"},\"constructor\":{\"notice\":\"Constructor of the contract.\"},\"createPromotion(address,uint64,uint256,uint48,uint8)\":{\"notice\":\"Creates a new promotion.\"},\"destroyPromotion(uint256,address)\":{\"notice\":\"Delete an inactive promotion and send promotion tokens back to the creator.\"},\"endPromotion(uint256,address)\":{\"notice\":\"End currently active promotion and send promotion tokens back to the creator.\"},\"extendPromotion(uint256,uint8)\":{\"notice\":\"Extend promotion by adding more epochs.\"},\"getCurrentEpochId(uint256)\":{\"notice\":\"Get the current epoch id of a promotion.\"},\"getPromotion(uint256)\":{\"notice\":\"Get settings for a specific promotion.\"},\"getRemainingRewards(uint256)\":{\"notice\":\"Get the total amount of tokens left to be rewarded.\"},\"getRewardsAmount(address,uint256,uint8[])\":{\"notice\":\"Get amount of tokens to be rewarded for a given epoch.\"},\"ticket()\":{\"notice\":\"Prize pool ticket for which the promotions are created.\"}},\"notice\":\"Contract to distribute rewards to depositors in a pool. This contract supports the creation of several promotions that can run simultaneously. In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract. This way, users simply need to hold their tickets to be eligible to claim rewards. Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TwabRewards.sol\":\"TwabRewards\"},\"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/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/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/TwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\\\";\\n\\nimport \\\"./interfaces/ITwabRewards.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 TwabRewards\\n * @author PoolTogether Inc Team\\n * @notice Contract to distribute rewards to depositors in a pool.\\n * This contract supports the creation of several promotions that can run simultaneously.\\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\\n * @dev This contract supports only one prize pool ticket.\\n * @dev This contract does not support the use of fee on transfer tokens.\\n */\\ncontract TwabRewards is ITwabRewards {\\n using SafeERC20 for IERC20;\\n\\n /* ============ Global Variables ============ */\\n\\n /// @notice Prize pool ticket for which the promotions are created.\\n ITicket public immutable ticket;\\n\\n /// @notice Period during which the promotion owner can't destroy a promotion.\\n uint32 public constant GRACE_PERIOD = 60 days;\\n\\n /// @notice Settings of each promotion.\\n mapping(uint256 => Promotion) internal _promotions;\\n\\n /**\\n * @notice Latest recorded promotion id.\\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\\n */\\n uint256 internal _latestPromotionId;\\n\\n /**\\n * @notice Keeps track of claimed rewards per user.\\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\\n */\\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\\n\\n /* ============ Events ============ */\\n\\n /**\\n * @notice Emitted when a promotion is created.\\n * @param promotionId Id of the newly created promotion\\n */\\n event PromotionCreated(uint256 indexed promotionId);\\n\\n /**\\n * @notice Emitted when a promotion is ended.\\n * @param promotionId Id of the promotion being ended\\n * @param recipient Address of the recipient that will receive the remaining rewards\\n * @param amount Amount of tokens transferred to the recipient\\n * @param epochNumber Epoch number at which the promotion ended\\n */\\n event PromotionEnded(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount,\\n uint8 epochNumber\\n );\\n\\n /**\\n * @notice Emitted when a promotion is destroyed.\\n * @param promotionId Id of the promotion being destroyed\\n * @param recipient Address of the recipient that will receive the unclaimed rewards\\n * @param amount Amount of tokens transferred to the recipient\\n */\\n event PromotionDestroyed(\\n uint256 indexed promotionId,\\n address indexed recipient,\\n uint256 amount\\n );\\n\\n /**\\n * @notice Emitted when a promotion is extended.\\n * @param promotionId Id of the promotion being extended\\n * @param numberOfEpochs Number of epochs the promotion has been extended by\\n */\\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\\n\\n /**\\n * @notice Emitted when rewards have been claimed.\\n * @param promotionId Id of the promotion for which epoch rewards were claimed\\n * @param epochIds Ids of the epochs being claimed\\n * @param user Address of the user for which the rewards were claimed\\n * @param amount Amount of tokens transferred to the recipient address\\n */\\n event RewardsClaimed(\\n uint256 indexed promotionId,\\n uint8[] epochIds,\\n address indexed user,\\n uint256 amount\\n );\\n\\n /* ============ Constructor ============ */\\n\\n /**\\n * @notice Constructor of the contract.\\n * @param _ticket Prize Pool ticket address for which the promotions will be created\\n */\\n constructor(ITicket _ticket) {\\n _requireTicket(_ticket);\\n ticket = _ticket;\\n }\\n\\n /* ============ External Functions ============ */\\n\\n /// @inheritdoc ITwabRewards\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external override returns (uint256) {\\n require(_tokensPerEpoch > 0, \\\"TwabRewards/tokens-not-zero\\\");\\n require(_epochDuration > 0, \\\"TwabRewards/duration-not-zero\\\");\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n uint256 _nextPromotionId = _latestPromotionId + 1;\\n _latestPromotionId = _nextPromotionId;\\n\\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\\n\\n _promotions[_nextPromotionId] = Promotion({\\n creator: msg.sender,\\n startTimestamp: _startTimestamp,\\n numberOfEpochs: _numberOfEpochs,\\n epochDuration: _epochDuration,\\n createdAt: uint48(block.timestamp),\\n token: _token,\\n tokensPerEpoch: _tokensPerEpoch,\\n rewardsUnclaimed: _amount\\n });\\n\\n uint256 _beforeBalance = _token.balanceOf(address(this));\\n\\n _token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n uint256 _afterBalance = _token.balanceOf(address(this));\\n\\n require(_beforeBalance + _amount == _afterBalance, \\\"TwabRewards/promo-amount-diff\\\");\\n\\n emit PromotionCreated(_nextPromotionId);\\n\\n return _nextPromotionId;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\\n\\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\\n\\n _promotion.token.safeTransfer(_to, _remainingRewards);\\n\\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\\n require(_to != address(0), \\\"TwabRewards/payee-not-zero-addr\\\");\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionCreator(_promotion);\\n\\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\\n uint256 _promotionCreatedAt = _promotion.createdAt;\\n\\n uint256 _gracePeriodEndTimestamp = (\\n _promotionEndTimestamp < _promotionCreatedAt\\n ? _promotionCreatedAt\\n : _promotionEndTimestamp\\n ) + GRACE_PERIOD;\\n\\n require(block.timestamp >= _gracePeriodEndTimestamp, \\\"TwabRewards/grace-period-active\\\");\\n\\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\\n delete _promotions[_promotionId];\\n\\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\\n\\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\\n external\\n override\\n returns (bool)\\n {\\n _requireNumberOfEpochs(_numberOfEpochs);\\n\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n _requirePromotionActive(_promotion);\\n\\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\\n\\n require(\\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\\n \\\"TwabRewards/epochs-over-limit\\\"\\n );\\n\\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\\n\\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\\n\\n _promotions[_promotionId].rewardsUnclaimed += _amount;\\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\\n\\n emit PromotionExtended(_promotionId, _numberOfEpochs);\\n\\n return true;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external override returns (uint256) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _rewardsAmount;\\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\\n uint256 _epochIdsLength = _epochIds.length;\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n uint8 _epochId = _epochIds[index];\\n\\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \\\"TwabRewards/rewards-claimed\\\");\\n\\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\\n }\\n\\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\\n\\n _promotion.token.safeTransfer(_user, _rewardsAmount);\\n\\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\\n\\n return _rewardsAmount;\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\\n return _getPromotion(_promotionId);\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\\n return _getCurrentEpochId(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\\n return _getRemainingRewards(_getPromotion(_promotionId));\\n }\\n\\n /// @inheritdoc ITwabRewards\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view override returns (uint256[] memory) {\\n Promotion memory _promotion = _getPromotion(_promotionId);\\n\\n uint256 _epochIdsLength = _epochIds.length;\\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\\n\\n for (uint256 index = 0; index < _epochIdsLength; index++) {\\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\\n _rewardsAmount[index] = 0;\\n } else {\\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\\n }\\n }\\n\\n return _rewardsAmount;\\n }\\n\\n /* ============ Internal Functions ============ */\\n\\n /**\\n * @notice Determine if address passed is actually a ticket.\\n * @param _ticket Address to check\\n */\\n function _requireTicket(ITicket _ticket) internal view {\\n require(address(_ticket) != address(0), \\\"TwabRewards/ticket-not-zero-addr\\\");\\n\\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\\n abi.encodePacked(_ticket.controller.selector)\\n );\\n\\n require(\\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\\n \\\"TwabRewards/invalid-ticket\\\"\\n );\\n }\\n\\n /**\\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\\n * @param _numberOfEpochs Number of epochs to check\\n */\\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\\n require(_numberOfEpochs > 0, \\\"TwabRewards/epochs-not-zero\\\");\\n }\\n\\n /**\\n * @notice Determine if a promotion is active.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionActive(Promotion memory _promotion) internal view {\\n require(\\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\\n \\\"TwabRewards/promotion-inactive\\\"\\n );\\n }\\n\\n /**\\n * @notice Determine if msg.sender is the promotion creator.\\n * @param _promotion Promotion to check\\n */\\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\\n require(msg.sender == _promotion.creator, \\\"TwabRewards/only-promo-creator\\\");\\n }\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @dev Will revert if the promotion does not exist.\\n * @param _promotionId Promotion id to get settings for\\n * @return Promotion settings\\n */\\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\\n Promotion memory _promotion = _promotions[_promotionId];\\n require(_promotion.creator != address(0), \\\"TwabRewards/invalid-promotion\\\");\\n return _promotion;\\n }\\n\\n /**\\n * @notice Compute promotion end timestamp.\\n * @param _promotion Promotion to compute end timestamp for\\n * @return Promotion end timestamp\\n */\\n function _getPromotionEndTimestamp(Promotion memory _promotion)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return\\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\\n }\\n }\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @dev We return the current epoch id if the promotion has not ended.\\n * If the current timestamp is before the promotion start timestamp, we return 0.\\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\\n * @param _promotion Promotion to get current epoch for\\n * @return Epoch id\\n */\\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\\n uint256 _currentEpochId;\\n\\n if (block.timestamp > _promotion.startTimestamp) {\\n unchecked {\\n _currentEpochId =\\n (block.timestamp - _promotion.startTimestamp) /\\n _promotion.epochDuration;\\n }\\n }\\n\\n return _currentEpochId;\\n }\\n\\n /**\\n * @notice Get reward amount for a specific user.\\n * @dev Rewards can only be calculated once the epoch is over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @param _user User to get reward amount for\\n * @param _promotion Promotion from which the epoch is\\n * @param _epochId Epoch id to get reward amount for\\n * @return Reward amount\\n */\\n function _calculateRewardAmount(\\n address _user,\\n Promotion memory _promotion,\\n uint8 _epochId\\n ) internal view returns (uint256) {\\n uint64 _epochDuration = _promotion.epochDuration;\\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\\n\\n require(block.timestamp >= _epochEndTimestamp, \\\"TwabRewards/epoch-not-over\\\");\\n require(_epochId < _promotion.numberOfEpochs, \\\"TwabRewards/invalid-epoch-id\\\");\\n\\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\\n _user,\\n _epochStartTimestamp,\\n _epochEndTimestamp\\n );\\n\\n if (_averageBalance > 0) {\\n uint64[] memory _epochStartTimestamps = new uint64[](1);\\n _epochStartTimestamps[0] = _epochStartTimestamp;\\n\\n uint64[] memory _epochEndTimestamps = new uint64[](1);\\n _epochEndTimestamps[0] = _epochEndTimestamp;\\n\\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\\n _epochStartTimestamps,\\n _epochEndTimestamps\\n )[0];\\n\\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\\n return 0;\\n }\\n\\n return\\n _promotion.tokensPerEpoch *\\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\\n }\\n\\n /**\\n * @notice Set boolean value for a specific epoch.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0011\\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\\n We get: 0000 0001 << 2 = 0000 0100\\n We then OR the mask with the word to set the value.\\n We get: 0110 0011 | 0000 0100 = 0110 0111\\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\\n * @param _epochId Id of the epoch to set the boolean for\\n * @return Tightly packed epoch ids with the newly boolean value set\\n */\\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (uint256)\\n {\\n return _userClaimedEpochs | (uint256(1) << _epochId);\\n }\\n\\n /**\\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\\n * @dev Bits are stored in a uint256 from right to left.\\n Let's take the example of the following 8 bits word. 0110 0111\\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\\n We get: 0110 0111 >> 2 = 0001 1001\\n We then get the value of the last bit by masking with 1.\\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\\n We then return the boolean value true since the last bit is 1.\\n * @param _userClaimedEpochs Record of epochs already claimed by the user\\n * @param _epochId Epoch id to check\\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\\n */\\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\\n internal\\n pure\\n returns (bool)\\n {\\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\\n }\\n}\\n\",\"keccak256\":\"0x19cf7e6f5b339bb8e553268b1dbafd3e12a00239bc642be87dc363d4832542a8\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ITwabRewards.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity 0.8.6;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n * @title PoolTogether V4 ITwabRewards\\n * @author PoolTogether Inc Team\\n * @notice TwabRewards contract interface.\\n */\\ninterface ITwabRewards {\\n /**\\n * @notice Struct to keep track of each promotion's settings.\\n * @param creator Addresss of the promotion creator\\n * @param startTimestamp Timestamp at which the promotion starts\\n * @param numberOfEpochs Number of epochs the promotion will last for\\n * @param epochDuration Duration of one epoch in seconds\\n * @param createdAt Timestamp at which the promotion was created\\n * @param token Address of the token to be distributed as reward\\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\\n */\\n struct Promotion {\\n address creator;\\n uint64 startTimestamp;\\n uint8 numberOfEpochs;\\n uint48 epochDuration;\\n uint48 createdAt;\\n IERC20 token;\\n uint256 tokensPerEpoch;\\n uint256 rewardsUnclaimed;\\n }\\n\\n /**\\n * @notice Creates a new promotion.\\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\\n * So the first promotion will have id 1, the second 2, etc.\\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\\n * This scenario could happen if the token supplied is a fee on transfer one.\\n * @param _token Address of the token to be distributed\\n * @param _startTimestamp Timestamp at which the promotion starts\\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\\n * @param _epochDuration Duration of one epoch in seconds\\n * @param _numberOfEpochs Number of epochs the promotion will last for\\n * @return Id of the newly created promotion\\n */\\n function createPromotion(\\n IERC20 _token,\\n uint64 _startTimestamp,\\n uint256 _tokensPerEpoch,\\n uint48 _epochDuration,\\n uint8 _numberOfEpochs\\n ) external returns (uint256);\\n\\n /**\\n * @notice End currently active promotion and send promotion tokens back to the creator.\\n * @dev Will only send back tokens from the epochs that have not completed.\\n * @param _promotionId Promotion id to end\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return true if operation was successful\\n */\\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\\n * @dev Will send back all the tokens that have not been claimed yet by users.\\n * @dev This function will revert if the promotion is still active.\\n * @dev This function will revert if the grace period is not over yet.\\n * @param _promotionId Promotion id to destroy\\n * @param _to Address that will receive the remaining tokens if there are any left\\n * @return True if operation was successful\\n */\\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\\n\\n /**\\n * @notice Extend promotion by adding more epochs.\\n * @param _promotionId Id of the promotion to extend\\n * @param _numberOfEpochs Number of epochs to add\\n * @return True if the operation was successful\\n */\\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\\n\\n /**\\n * @notice Claim rewards for a given promotion and epoch.\\n * @dev Rewards can be claimed on behalf of a user.\\n * @dev Rewards can only be claimed for a past epoch.\\n * @param _user Address of the user to claim rewards for\\n * @param _promotionId Id of the promotion to claim rewards for\\n * @param _epochIds Epoch ids to claim rewards for\\n * @return Total amount of rewards claimed\\n */\\n function claimRewards(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external returns (uint256);\\n\\n /**\\n * @notice Get settings for a specific promotion.\\n * @param _promotionId Id of the promotion to get settings for\\n * @return Promotion settings\\n */\\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\\n\\n /**\\n * @notice Get the current epoch id of a promotion.\\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\\n * @param _promotionId Id of the promotion to get current epoch for\\n * @return Current epoch id of the promotion\\n */\\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get the total amount of tokens left to be rewarded.\\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\\n * @return Amount of tokens left to be rewarded\\n */\\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\\n\\n /**\\n * @notice Get amount of tokens to be rewarded for a given epoch.\\n * @dev Rewards amount can only be retrieved for epochs that are over.\\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\\n * @dev Will return 0 if the user average balance of tickets is 0.\\n * @dev Will be 0 if user has already claimed rewards for the epoch.\\n * @param _user Address of the user to get amount of rewards for\\n * @param _promotionId Id of the promotion from which the epoch is\\n * @param _epochIds Epoch ids to get reward amount for\\n * @return Amount of tokens per epoch to be rewarded\\n */\\n function getRewardsAmount(\\n address _user,\\n uint256 _promotionId,\\n uint8[] calldata _epochIds\\n ) external view returns (uint256[] memory);\\n}\\n\",\"keccak256\":\"0xbd96f3c1f80c16b2dcfbe0e9c3fd281044fef93c1db4d4c9d56dc3e2bf7ec47d\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002179380380620021798339810160408190526200003491620001c3565b6200003f8162000055565b60601b6001600160601b03191660805262000241565b6001600160a01b038116620000b15760405162461bcd60e51b815260206004820181905260248201527f54776162526577617264732f7469636b65742d6e6f742d7a65726f2d6164647260448201526064015b60405180910390fd5b60405163f77c479160e01b602082015260009081906001600160a01b0384169060240160408051601f1981840301815290829052620000f091620001ea565b600060405180830381855afa9150503d80600081146200012d576040519150601f19603f3d011682016040523d82523d6000602084013e62000132565b606091505b509150915081801562000146575060008151115b801562000170575080806020019051810190620001649190620001c3565b6001600160a01b031615155b620001be5760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f696e76616c69642d7469636b65740000000000006044820152606401620000a8565b505050565b600060208284031215620001d657600080fd5b8151620001e38162000228565b9392505050565b6000825160005b818110156200020d5760208186018101518583015201620001f1565b818111156200021d576000828501525b509190910192915050565b6001600160a01b03811681146200023e57600080fd5b50565b60805160601c611f0b6200026e600039600081816101820152818161127001526113c80152611f0b6000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806366cfae5e11610081578063b2456c3a1161005b578063b2456c3a146101cf578063c1a287e2146101e2578063f824d0fb1461020157600080fd5b806366cfae5e1461015c5780636cc25db71461017d578063a4958845146101bc57600080fd5b8063120468a0116100b2578063120468a01461011657806314fdecca1461012957806320555db11461014957600080fd5b8063096fe668146100ce5780630b011a16146100f6575b600080fd5b6100e16100dc366004611ada565b610214565b60405190151581526020015b60405180910390f35b610109610104366004611889565b610386565b6040516100ed9190611b82565b6100e1610124366004611aaa565b6104db565b61013c610137366004611a78565b610641565b6040516100ed9190611c75565b6100e1610157366004611aaa565b610691565b61016f61016a3660046119fc565b610861565b6040519081526020016100ed565b6101a47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ed565b61016f6101ca366004611a78565b610c98565b61016f6101dd366004611889565b610cab565b6101ec624f1a0081565b60405163ffffffff90911681526020016100ed565b61016f61020f366004611a78565b610e56565b600061021f82610e69565b600061022a84610ebf565b905061023581610fff565b60408101516102458160ff611dfe565b60ff168460ff16111561029f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f65706f6368732d6f7665722d6c696d697400000060448201526064015b60405180910390fd5b6102a98482611d51565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff9485160217905560c084015190916102fc91908716611d98565b90508060008088815260200190815260200160002060030160008282546103239190611d0d565b909155505060a0830151610342906001600160a01b0316333084611076565b60405160ff8616815286907fa9527ed49c1c2ab5449cfef5b611076ce228a0a0de4534874963b83abb6e7b469060200160405180910390a250600195945050505050565b6060600061039385610ebf565b90508260008167ffffffffffffffff8111156103b1576103b1611eaa565b6040519080825280602002602001820160405280156103da578160200160208202803683370190505b50905060005b828110156104cf5760008881526002602090815260408083206001600160a01b038d1684529091529020546104439088888481811061042157610421611e94565b90506020020160208101906104369190611b06565b60ff161c60019081161490565b1561046d57600082828151811061045c5761045c611e94565b6020026020010181815250506104bd565b61049e898589898581811061048457610484611e94565b90506020020160208101906104999190611b06565b61112d565b8282815181106104b0576104b0611e94565b6020026020010181815250505b806104c781611e4d565b9150506103e0565b50979650505050505050565b60006001600160a01b0382166105335760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b600061053e84610ebf565b9050610549816114a8565b61055281610fff565b600061055d82611501565b600086815260208190526040812080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b60ff8516021790559091506105a88361154d565b90508060008088815260200190815260200160002060030160008282546105cf9190611de7565b909155505060a08301516105ed906001600160a01b031686836115b1565b6040805182815260ff841660208201526001600160a01b0387169188917f98f89153fa6ee40b2edcd2e1ce4a5a9edfb2f74818016fc24e6cfe7b6fcd12a9910160405180910390a350600195945050505050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915261068b82610ebf565b92915050565b60006001600160a01b0382166106e95760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f70617965652d6e6f742d7a65726f2d61646472006044820152606401610296565b60006106f484610ebf565b90506106ff816114a8565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff16608083015190915065ffffffffffff166000624f1a0082841061074d578361074f565b825b6107599190611d0d565b9050804210156107ab5760405162461bcd60e51b815260206004820152601f60248201527f54776162526577617264732f67726163652d706572696f642d616374697665006044820152606401610296565b60e0840151600088815260208190526040812080547fffffff000000000000000000000000000000000000000000000000000000000016815560018101829055600281018290556003015560a085015161080f906001600160a01b031688836115b1565b866001600160a01b0316887f6f804f2ef186cd4b2a6740c084b86f557a497a1fcf3a6b073068a55c51187b6f8360405161084b91815260200190565b60405180910390a3506001979650505050505050565b60008084116108b25760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f746f6b656e732d6e6f742d7a65726f00000000006044820152606401610296565b60008365ffffffffffff161161090a5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f6475726174696f6e2d6e6f742d7a65726f0000006044820152606401610296565b61091382610e69565b600060015460016109249190611d0d565b60018190559050600061093a60ff851687611d98565b9050604051806101000160405280336001600160a01b031681526020018867ffffffffffffffff1681526020018560ff1681526020018665ffffffffffff1681526020014265ffffffffffff168152602001896001600160a01b031681526020018781526020018281525060008084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604082015181600001601c6101000a81548160ff021916908360ff16021790555060608201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060808201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a082015181600101600c6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816002015560e082015181600301559050506000886001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b0b91906001600160a01b0391909116815260200190565b60206040518083038186803b158015610b2357600080fd5b505afa158015610b37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5b9190611a91565b9050610b726001600160a01b038a16333085611076565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038b16906370a082319060240160206040518083038186803b158015610bcd57600080fd5b505afa158015610be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c059190611a91565b905080610c128484611d0d565b14610c5f5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f70726f6d6f2d616d6f756e742d646966660000006044820152606401610296565b60405184907faedc1797e973574eb0e43205c473287ca44eb1c9d0f677dbb0ec8cfc72bb68f390600090a2509198975050505050505050565b600061068b610ca683610ebf565b61154d565b600080610cb785610ebf565b60008681526002602090815260408083206001600160a01b038b1684529091528120549192509084825b81811015610da3576000888883818110610cfd57610cfd611e94565b9050602002016020810190610d129190611b06565b9050600160ff821685901c81161415610d6d5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f726577617264732d636c61696d656400000000006044820152606401610296565b610d788b878361112d565b610d829086611d0d565b9450600160ff82161b84179350508080610d9b90611e4d565b915050610ce1565b5060008881526002602090815260408083206001600160a01b038d16845282528083208590558a83529082905281206003018054859290610de5908490611de7565b909155505060a0840151610e03906001600160a01b03168a856115b1565b886001600160a01b0316887f446a5bb69110f4fa9a5802e85237a4281d1d27dbe989b22da4a75d9deae8c778898987604051610e4193929190611bf4565b60405180910390a35090979650505050505050565b600061068b610e6483610ebf565b611501565b60008160ff1611610ebc5760405162461bcd60e51b815260206004820152601b60248201527f54776162526577617264732f65706f6368732d6e6f742d7a65726f00000000006044820152606401610296565b50565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526000828152602081815260409182902082516101008101845281546001600160a01b0380821680845274010000000000000000000000000000000000000000830467ffffffffffffffff1695840195909552600160e01b90910460ff1694820194909452600182015465ffffffffffff8082166060840152660100000000000082041660808301526c01000000000000000000000000900490931660a0840152600281015460c08401526003015460e083015261068b5760405162461bcd60e51b815260206004820152601d60248201527f54776162526577617264732f696e76616c69642d70726f6d6f74696f6e0000006044820152606401610296565b604081015160608201516020830151429260ff1690910265ffffffffffff160167ffffffffffffffff1611610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f70726f6d6f74696f6e2d696e61637469766500006044820152606401610296565b6040516001600160a01b03808516602483015283166044820152606481018290526111279085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115ff565b50505050565b606082015160009065ffffffffffff168161114b60ff851683611db7565b856020015161115a9190611d25565b905060006111688383611d25565b90508067ffffffffffffffff164210156111c45760405162461bcd60e51b815260206004820152601a60248201527f54776162526577617264732f65706f63682d6e6f742d6f7665720000000000006044820152606401610296565b856040015160ff168560ff161061121d5760405162461bcd60e51b815260206004820152601c60248201527f54776162526577617264732f696e76616c69642d65706f63682d6964000000006044820152606401610296565b6040517f98b16f360000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015267ffffffffffffffff8085166024840152831660448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906398b16f369060640160206040518083038186803b1580156112b457600080fd5b505afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ec9190611a91565b905080156114985760408051600180825281830190925260009160208083019080368337019050509050838160008151811061132a5761132a611e94565b67ffffffffffffffff9290921660209283029190910190910152604080516001808252818301909252600091816020016020820280368337019050509050838160008151811061137c5761137c611e94565b67ffffffffffffffff909216602092830291909101909101526040517f8e6d536a0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638e6d536a906113ff9086908690600401611bc6565b60006040518083038186803b15801561141757600080fd5b505afa15801561142b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114539190810190611915565b60008151811061146557611465611e94565b6020026020010151905080848b60c001516114809190611d98565b61148a9190611d76565b9750505050505050506114a1565b60009450505050505b9392505050565b80516001600160a01b03163314610ebc5760405162461bcd60e51b815260206004820152601e60248201527f54776162526577617264732f6f6e6c792d70726f6d6f2d63726561746f7200006044820152606401610296565b600080826020015167ffffffffffffffff1642111561068b57826060015165ffffffffffff16836020015167ffffffffffffffff1642038161154557611545611e7e565b049392505050565b60408101516060820151602083015160009260ff1690910265ffffffffffff160167ffffffffffffffff1642111561158757506000919050565b61159082611501565b826040015160ff166115a29190611de7565b8260c0015161068b9190611d98565b6040516001600160a01b0383166024820152604481018290526115fa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016110c3565b505050565b6000611654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e49092919063ffffffff16565b8051909150156115fa578080602001905181019061167291906119da565b6115fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610296565b60606116f384846000856116fb565b949350505050565b6060824710156117735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610296565b843b6117c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610296565b600080866001600160a01b031685876040516117dd9190611b66565b60006040518083038185875af1925050503d806000811461181a576040519150601f19603f3d011682016040523d82523d6000602084013e61181f565b606091505b509150915061182f82828661183a565b979650505050505050565b606083156118495750816114a1565b8251156118595782518084602001fd5b8160405162461bcd60e51b81526004016102969190611c42565b803560ff8116811461188457600080fd5b919050565b6000806000806060858703121561189f57600080fd5b84356118aa81611ec0565b935060208501359250604085013567ffffffffffffffff808211156118ce57600080fd5b818701915087601f8301126118e257600080fd5b8135818111156118f157600080fd5b8860208260051b850101111561190657600080fd5b95989497505060200194505050565b6000602080838503121561192857600080fd5b825167ffffffffffffffff8082111561194057600080fd5b818501915085601f83011261195457600080fd5b81518181111561196657611966611eaa565b8060051b604051601f19603f8301168101818110858211171561198b5761198b611eaa565b604052828152858101935084860182860187018a10156119aa57600080fd5b600095505b838610156119cd5780518552600195909501949386019386016119af565b5098975050505050505050565b6000602082840312156119ec57600080fd5b815180151581146114a157600080fd5b600080600080600060a08688031215611a1457600080fd5b8535611a1f81611ec0565b9450602086013567ffffffffffffffff81168114611a3c57600080fd5b935060408601359250606086013565ffffffffffff81168114611a5e57600080fd5b9150611a6c60808701611873565b90509295509295909350565b600060208284031215611a8a57600080fd5b5035919050565b600060208284031215611aa357600080fd5b5051919050565b60008060408385031215611abd57600080fd5b823591506020830135611acf81611ec0565b809150509250929050565b60008060408385031215611aed57600080fd5b82359150611afd60208401611873565b90509250929050565b600060208284031215611b1857600080fd5b6114a182611873565b600081518084526020808501945080840160005b83811015611b5b57815167ffffffffffffffff1687529582019590820190600101611b35565b509495945050505050565b60008251611b78818460208701611e21565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015611bba57835183529284019291840191600101611b9e565b50909695505050505050565b604081526000611bd96040830185611b21565b8281036020840152611beb8185611b21565b95945050505050565b6040808252810183905260008460608301825b86811015611c2f5760ff611c1a84611873565b16825260209283019290910190600101611c07565b5060209390930193909352509392505050565b6020815260008251806020840152611c61816040850160208701611e21565b601f01601f19169190910160400192915050565b6000610100820190506001600160a01b03835116825267ffffffffffffffff602084015116602083015260ff604084015116604083015265ffffffffffff60608401511660608301526080830151611cd7608084018265ffffffffffff169052565b5060a0830151611cf260a08401826001600160a01b03169052565b5060c083015160c083015260e083015160e083015292915050565b60008219821115611d2057611d20611e68565b500190565b600067ffffffffffffffff808316818516808303821115611d4857611d48611e68565b01949350505050565b600060ff821660ff84168060ff03821115611d6e57611d6e611e68565b019392505050565b600082611d9357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611db257611db2611e68565b500290565b600067ffffffffffffffff80831681851681830481118215151615611dde57611dde611e68565b02949350505050565b600082821015611df957611df9611e68565b500390565b600060ff821660ff841680821015611e1857611e18611e68565b90039392505050565b60005b83811015611e3c578181015183820152602001611e24565b838111156111275750506000910152565b6000600019821415611e6157611e61611e68565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ebc57600080fdfea2646970667358221220dd0f863bf7c0712f99be832d8b4c5e86b92c1a355b98000d1091ee80eb17e48764736f6c63430008060033", "devdoc": { "author": "PoolTogether Inc Team", "details": "This contract supports only one prize pool ticket.This contract does not support the use of fee on transfer tokens.", @@ -660,24 +660,24 @@ "storageLayout": { "storage": [ { - "astId": 15925, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12394, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_promotions", "offset": 0, "slot": "0", - "type": "t_mapping(t_uint256,t_struct(Promotion)17216_storage)" + "type": "t_mapping(t_uint256,t_struct(Promotion)13793_storage)" }, { - "astId": 15928, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12397, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_latestPromotionId", "offset": 0, "slot": "1", "type": "t_uint256" }, { - "astId": 15935, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 12404, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "_claimedEpochs", "offset": 0, "slot": "2", @@ -709,76 +709,76 @@ "numberOfBytes": "32", "value": "t_mapping(t_address,t_uint256)" }, - "t_mapping(t_uint256,t_struct(Promotion)17216_storage)": { + "t_mapping(t_uint256,t_struct(Promotion)13793_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct ITwabRewards.Promotion)", "numberOfBytes": "32", - "value": "t_struct(Promotion)17216_storage" + "value": "t_struct(Promotion)13793_storage" }, - "t_struct(Promotion)17216_storage": { + "t_struct(Promotion)13793_storage": { "encoding": "inplace", "label": "struct ITwabRewards.Promotion", "members": [ { - "astId": 17200, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13777, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "creator", "offset": 0, "slot": "0", "type": "t_address" }, { - "astId": 17202, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13779, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "startTimestamp", "offset": 20, "slot": "0", "type": "t_uint64" }, { - "astId": 17204, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13781, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "numberOfEpochs", "offset": 28, "slot": "0", "type": "t_uint8" }, { - "astId": 17206, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13783, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "epochDuration", "offset": 0, "slot": "1", "type": "t_uint48" }, { - "astId": 17208, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13785, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "createdAt", "offset": 6, "slot": "1", "type": "t_uint48" }, { - "astId": 17211, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13788, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "token", "offset": 12, "slot": "1", "type": "t_contract(IERC20)663" }, { - "astId": 17213, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13790, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "tokensPerEpoch", "offset": 0, "slot": "2", "type": "t_uint256" }, { - "astId": 17215, - "contract": "@pooltogether/v4-periphery/contracts/TwabRewards.sol:TwabRewards", + "astId": 13792, + "contract": "contracts/TwabRewards.sol:TwabRewards", "label": "rewardsUnclaimed", "offset": 0, "slot": "3", diff --git a/deployments/mainnet/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json b/deployments/mainnet/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json new file mode 100644 index 0000000..ebd3212 --- /dev/null +++ b/deployments/mainnet/solcInputs/45c8f80dfd4edb590489bcbaf8232d24.json @@ -0,0 +1,255 @@ +{ + "language": "Solidity", + "sources": { + "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n" + }, + "@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" + }, + "contracts/TwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/ITicket.sol\";\n\nimport \"./interfaces/ITwabRewards.sol\";\n\n/**\n * @title PoolTogether V4 TwabRewards\n * @author PoolTogether Inc Team\n * @notice Contract to distribute rewards to depositors in a pool.\n * This contract supports the creation of several promotions that can run simultaneously.\n * In order to calculate user rewards, we use the TWAB (Time-Weighted Average Balance) from the Ticket contract.\n * This way, users simply need to hold their tickets to be eligible to claim rewards.\n * Rewards are calculated based on the average amount of tickets they hold during the epoch duration.\n * @dev This contract supports only one prize pool ticket.\n * @dev This contract does not support the use of fee on transfer tokens.\n */\ncontract TwabRewards is ITwabRewards {\n using SafeERC20 for IERC20;\n\n /* ============ Global Variables ============ */\n\n /// @notice Prize pool ticket for which the promotions are created.\n ITicket public immutable ticket;\n\n /// @notice Period during which the promotion owner can't destroy a promotion.\n uint32 public constant GRACE_PERIOD = 60 days;\n\n /// @notice Settings of each promotion.\n mapping(uint256 => Promotion) internal _promotions;\n\n /**\n * @notice Latest recorded promotion id.\n * @dev Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc.\n */\n uint256 internal _latestPromotionId;\n\n /**\n * @notice Keeps track of claimed rewards per user.\n * @dev _claimedEpochs[promotionId][user] => claimedEpochs\n * @dev We pack epochs claimed by a user into a uint256. So we can't store more than 256 epochs.\n */\n mapping(uint256 => mapping(address => uint256)) internal _claimedEpochs;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when a promotion is created.\n * @param promotionId Id of the newly created promotion\n */\n event PromotionCreated(uint256 indexed promotionId);\n\n /**\n * @notice Emitted when a promotion is ended.\n * @param promotionId Id of the promotion being ended\n * @param recipient Address of the recipient that will receive the remaining rewards\n * @param amount Amount of tokens transferred to the recipient\n * @param epochNumber Epoch number at which the promotion ended\n */\n event PromotionEnded(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount,\n uint8 epochNumber\n );\n\n /**\n * @notice Emitted when a promotion is destroyed.\n * @param promotionId Id of the promotion being destroyed\n * @param recipient Address of the recipient that will receive the unclaimed rewards\n * @param amount Amount of tokens transferred to the recipient\n */\n event PromotionDestroyed(\n uint256 indexed promotionId,\n address indexed recipient,\n uint256 amount\n );\n\n /**\n * @notice Emitted when a promotion is extended.\n * @param promotionId Id of the promotion being extended\n * @param numberOfEpochs Number of epochs the promotion has been extended by\n */\n event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);\n\n /**\n * @notice Emitted when rewards have been claimed.\n * @param promotionId Id of the promotion for which epoch rewards were claimed\n * @param epochIds Ids of the epochs being claimed\n * @param user Address of the user for which the rewards were claimed\n * @param amount Amount of tokens transferred to the recipient address\n */\n event RewardsClaimed(\n uint256 indexed promotionId,\n uint8[] epochIds,\n address indexed user,\n uint256 amount\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor of the contract.\n * @param _ticket Prize Pool ticket address for which the promotions will be created\n */\n constructor(ITicket _ticket) {\n _requireTicket(_ticket);\n ticket = _ticket;\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITwabRewards\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external override returns (uint256) {\n require(_tokensPerEpoch > 0, \"TwabRewards/tokens-not-zero\");\n require(_epochDuration > 0, \"TwabRewards/duration-not-zero\");\n _requireNumberOfEpochs(_numberOfEpochs);\n\n uint256 _nextPromotionId = _latestPromotionId + 1;\n _latestPromotionId = _nextPromotionId;\n\n uint256 _amount = _tokensPerEpoch * _numberOfEpochs;\n\n _promotions[_nextPromotionId] = Promotion({\n creator: msg.sender,\n startTimestamp: _startTimestamp,\n numberOfEpochs: _numberOfEpochs,\n epochDuration: _epochDuration,\n createdAt: uint48(block.timestamp),\n token: _token,\n tokensPerEpoch: _tokensPerEpoch,\n rewardsUnclaimed: _amount\n });\n\n uint256 _beforeBalance = _token.balanceOf(address(this));\n\n _token.safeTransferFrom(msg.sender, address(this), _amount);\n\n uint256 _afterBalance = _token.balanceOf(address(this));\n\n require(_beforeBalance + _amount == _afterBalance, \"TwabRewards/promo-amount-diff\");\n\n emit PromotionCreated(_nextPromotionId);\n\n return _nextPromotionId;\n }\n\n /// @inheritdoc ITwabRewards\n function endPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n _requirePromotionActive(_promotion);\n\n uint8 _epochNumber = uint8(_getCurrentEpochId(_promotion));\n _promotions[_promotionId].numberOfEpochs = _epochNumber;\n\n uint256 _remainingRewards = _getRemainingRewards(_promotion);\n _promotions[_promotionId].rewardsUnclaimed -= _remainingRewards;\n\n _promotion.token.safeTransfer(_to, _remainingRewards);\n\n emit PromotionEnded(_promotionId, _to, _remainingRewards, _epochNumber);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function destroyPromotion(uint256 _promotionId, address _to) external override returns (bool) {\n require(_to != address(0), \"TwabRewards/payee-not-zero-addr\");\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionCreator(_promotion);\n\n uint256 _promotionEndTimestamp = _getPromotionEndTimestamp(_promotion);\n uint256 _promotionCreatedAt = _promotion.createdAt;\n\n uint256 _gracePeriodEndTimestamp = (\n _promotionEndTimestamp < _promotionCreatedAt\n ? _promotionCreatedAt\n : _promotionEndTimestamp\n ) + GRACE_PERIOD;\n\n require(block.timestamp >= _gracePeriodEndTimestamp, \"TwabRewards/grace-period-active\");\n\n uint256 _rewardsUnclaimed = _promotion.rewardsUnclaimed;\n delete _promotions[_promotionId];\n\n _promotion.token.safeTransfer(_to, _rewardsUnclaimed);\n\n emit PromotionDestroyed(_promotionId, _to, _rewardsUnclaimed);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs)\n external\n override\n returns (bool)\n {\n _requireNumberOfEpochs(_numberOfEpochs);\n\n Promotion memory _promotion = _getPromotion(_promotionId);\n _requirePromotionActive(_promotion);\n\n uint8 _currentNumberOfEpochs = _promotion.numberOfEpochs;\n\n require(\n _numberOfEpochs <= (type(uint8).max - _currentNumberOfEpochs),\n \"TwabRewards/epochs-over-limit\"\n );\n\n _promotions[_promotionId].numberOfEpochs = _currentNumberOfEpochs + _numberOfEpochs;\n\n uint256 _amount = _numberOfEpochs * _promotion.tokensPerEpoch;\n\n _promotions[_promotionId].rewardsUnclaimed += _amount;\n _promotion.token.safeTransferFrom(msg.sender, address(this), _amount);\n\n emit PromotionExtended(_promotionId, _numberOfEpochs);\n\n return true;\n }\n\n /// @inheritdoc ITwabRewards\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external override returns (uint256) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _rewardsAmount;\n uint256 _userClaimedEpochs = _claimedEpochs[_promotionId][_user];\n uint256 _epochIdsLength = _epochIds.length;\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n uint8 _epochId = _epochIds[index];\n\n require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), \"TwabRewards/rewards-claimed\");\n\n _rewardsAmount += _calculateRewardAmount(_user, _promotion, _epochId);\n _userClaimedEpochs = _updateClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n\n _claimedEpochs[_promotionId][_user] = _userClaimedEpochs;\n _promotions[_promotionId].rewardsUnclaimed -= _rewardsAmount;\n\n _promotion.token.safeTransfer(_user, _rewardsAmount);\n\n emit RewardsClaimed(_promotionId, _epochIds, _user, _rewardsAmount);\n\n return _rewardsAmount;\n }\n\n /// @inheritdoc ITwabRewards\n function getPromotion(uint256 _promotionId) external view override returns (Promotion memory) {\n return _getPromotion(_promotionId);\n }\n\n /// @inheritdoc ITwabRewards\n function getCurrentEpochId(uint256 _promotionId) external view override returns (uint256) {\n return _getCurrentEpochId(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRemainingRewards(uint256 _promotionId) external view override returns (uint256) {\n return _getRemainingRewards(_getPromotion(_promotionId));\n }\n\n /// @inheritdoc ITwabRewards\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view override returns (uint256[] memory) {\n Promotion memory _promotion = _getPromotion(_promotionId);\n\n uint256 _epochIdsLength = _epochIds.length;\n uint256[] memory _rewardsAmount = new uint256[](_epochIdsLength);\n\n for (uint256 index = 0; index < _epochIdsLength; index++) {\n if (_isClaimedEpoch(_claimedEpochs[_promotionId][_user], _epochIds[index])) {\n _rewardsAmount[index] = 0;\n } else {\n _rewardsAmount[index] = _calculateRewardAmount(_user, _promotion, _epochIds[index]);\n }\n }\n\n return _rewardsAmount;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Determine if address passed is actually a ticket.\n * @param _ticket Address to check\n */\n function _requireTicket(ITicket _ticket) internal view {\n require(address(_ticket) != address(0), \"TwabRewards/ticket-not-zero-addr\");\n\n (bool succeeded, bytes memory data) = address(_ticket).staticcall(\n abi.encodePacked(_ticket.controller.selector)\n );\n\n require(\n succeeded && data.length > 0 && abi.decode(data, (uint160)) != 0,\n \"TwabRewards/invalid-ticket\"\n );\n }\n\n /**\n * @notice Allow a promotion to be created or extended only by a positive number of epochs.\n * @param _numberOfEpochs Number of epochs to check\n */\n function _requireNumberOfEpochs(uint8 _numberOfEpochs) internal pure {\n require(_numberOfEpochs > 0, \"TwabRewards/epochs-not-zero\");\n }\n\n /**\n * @notice Determine if a promotion is active.\n * @param _promotion Promotion to check\n */\n function _requirePromotionActive(Promotion memory _promotion) internal view {\n require(\n _getPromotionEndTimestamp(_promotion) > block.timestamp,\n \"TwabRewards/promotion-inactive\"\n );\n }\n\n /**\n * @notice Determine if msg.sender is the promotion creator.\n * @param _promotion Promotion to check\n */\n function _requirePromotionCreator(Promotion memory _promotion) internal view {\n require(msg.sender == _promotion.creator, \"TwabRewards/only-promo-creator\");\n }\n\n /**\n * @notice Get settings for a specific promotion.\n * @dev Will revert if the promotion does not exist.\n * @param _promotionId Promotion id to get settings for\n * @return Promotion settings\n */\n function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory) {\n Promotion memory _promotion = _promotions[_promotionId];\n require(_promotion.creator != address(0), \"TwabRewards/invalid-promotion\");\n return _promotion;\n }\n\n /**\n * @notice Compute promotion end timestamp.\n * @param _promotion Promotion to compute end timestamp for\n * @return Promotion end timestamp\n */\n function _getPromotionEndTimestamp(Promotion memory _promotion)\n internal\n pure\n returns (uint256)\n {\n unchecked {\n return\n _promotion.startTimestamp + (_promotion.epochDuration * _promotion.numberOfEpochs);\n }\n }\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @dev We return the current epoch id if the promotion has not ended.\n * If the current timestamp is before the promotion start timestamp, we return 0.\n * Otherwise, we return the epoch id at the current timestamp. This could be greater than the number of epochs of the promotion.\n * @param _promotion Promotion to get current epoch for\n * @return Epoch id\n */\n function _getCurrentEpochId(Promotion memory _promotion) internal view returns (uint256) {\n uint256 _currentEpochId;\n\n if (block.timestamp > _promotion.startTimestamp) {\n unchecked {\n _currentEpochId =\n (block.timestamp - _promotion.startTimestamp) /\n _promotion.epochDuration;\n }\n }\n\n return _currentEpochId;\n }\n\n /**\n * @notice Get reward amount for a specific user.\n * @dev Rewards can only be calculated once the epoch is over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @param _user User to get reward amount for\n * @param _promotion Promotion from which the epoch is\n * @param _epochId Epoch id to get reward amount for\n * @return Reward amount\n */\n function _calculateRewardAmount(\n address _user,\n Promotion memory _promotion,\n uint8 _epochId\n ) internal view returns (uint256) {\n uint64 _epochDuration = _promotion.epochDuration;\n uint64 _epochStartTimestamp = _promotion.startTimestamp + (_epochDuration * _epochId);\n uint64 _epochEndTimestamp = _epochStartTimestamp + _epochDuration;\n\n require(block.timestamp >= _epochEndTimestamp, \"TwabRewards/epoch-not-over\");\n require(_epochId < _promotion.numberOfEpochs, \"TwabRewards/invalid-epoch-id\");\n\n uint256 _averageBalance = ticket.getAverageBalanceBetween(\n _user,\n _epochStartTimestamp,\n _epochEndTimestamp\n );\n\n if (_averageBalance > 0) {\n uint64[] memory _epochStartTimestamps = new uint64[](1);\n _epochStartTimestamps[0] = _epochStartTimestamp;\n\n uint64[] memory _epochEndTimestamps = new uint64[](1);\n _epochEndTimestamps[0] = _epochEndTimestamp;\n\n uint256 _averageTotalSupply = ticket.getAverageTotalSuppliesBetween(\n _epochStartTimestamps,\n _epochEndTimestamps\n )[0];\n\n return (_promotion.tokensPerEpoch * _averageBalance) / _averageTotalSupply;\n }\n\n return 0;\n }\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotion Promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function _getRemainingRewards(Promotion memory _promotion) internal view returns (uint256) {\n if (block.timestamp > _getPromotionEndTimestamp(_promotion)) {\n return 0;\n }\n\n return\n _promotion.tokensPerEpoch *\n (_promotion.numberOfEpochs - _getCurrentEpochId(_promotion));\n }\n\n /**\n * @notice Set boolean value for a specific epoch.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0011\n To set the boolean value to 1 for the epoch id 2, we need to create a mask by shifting 1 to the left by 2 bits.\n We get: 0000 0001 << 2 = 0000 0100\n We then OR the mask with the word to set the value.\n We get: 0110 0011 | 0000 0100 = 0110 0111\n * @param _userClaimedEpochs Tightly packed epoch ids with their boolean values\n * @param _epochId Id of the epoch to set the boolean for\n * @return Tightly packed epoch ids with the newly boolean value set\n */\n function _updateClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (uint256)\n {\n return _userClaimedEpochs | (uint256(1) << _epochId);\n }\n\n /**\n * @notice Check if rewards of an epoch for a given promotion have already been claimed by the user.\n * @dev Bits are stored in a uint256 from right to left.\n Let's take the example of the following 8 bits word. 0110 0111\n To retrieve the boolean value for the epoch id 2, we need to shift the word to the right by 2 bits.\n We get: 0110 0111 >> 2 = 0001 1001\n We then get the value of the last bit by masking with 1.\n We get: 0001 1001 & 0000 0001 = 0000 0001 = 1\n We then return the boolean value true since the last bit is 1.\n * @param _userClaimedEpochs Record of epochs already claimed by the user\n * @param _epochId Epoch id to check\n * @return true if the rewards have already been claimed for the given epoch, false otherwise\n */\n function _isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n internal\n pure\n returns (bool)\n {\n return (_userClaimedEpochs >> _epochId) & uint256(1) == 1;\n }\n}\n" + }, + "@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" + }, + "@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" + }, + "contracts/interfaces/ITwabRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/**\n * @title PoolTogether V4 ITwabRewards\n * @author PoolTogether Inc Team\n * @notice TwabRewards contract interface.\n */\ninterface ITwabRewards {\n /**\n * @notice Struct to keep track of each promotion's settings.\n * @param creator Addresss of the promotion creator\n * @param startTimestamp Timestamp at which the promotion starts\n * @param numberOfEpochs Number of epochs the promotion will last for\n * @param epochDuration Duration of one epoch in seconds\n * @param createdAt Timestamp at which the promotion was created\n * @param token Address of the token to be distributed as reward\n * @param tokensPerEpoch Number of tokens to be distributed per epoch\n * @param rewardsUnclaimed Amount of rewards that have not been claimed yet\n */\n struct Promotion {\n address creator;\n uint64 startTimestamp;\n uint8 numberOfEpochs;\n uint48 epochDuration;\n uint48 createdAt;\n IERC20 token;\n uint256 tokensPerEpoch;\n uint256 rewardsUnclaimed;\n }\n\n /**\n * @notice Creates a new promotion.\n * @dev For sake of simplicity, `msg.sender` will be the creator of the promotion.\n * @dev `_latestPromotionId` starts at 0 and is incremented by 1 for each new promotion.\n * So the first promotion will have id 1, the second 2, etc.\n * @dev The transaction will revert if the amount of reward tokens provided is not equal to `_tokensPerEpoch * _numberOfEpochs`.\n * This scenario could happen if the token supplied is a fee on transfer one.\n * @param _token Address of the token to be distributed\n * @param _startTimestamp Timestamp at which the promotion starts\n * @param _tokensPerEpoch Number of tokens to be distributed per epoch\n * @param _epochDuration Duration of one epoch in seconds\n * @param _numberOfEpochs Number of epochs the promotion will last for\n * @return Id of the newly created promotion\n */\n function createPromotion(\n IERC20 _token,\n uint64 _startTimestamp,\n uint256 _tokensPerEpoch,\n uint48 _epochDuration,\n uint8 _numberOfEpochs\n ) external returns (uint256);\n\n /**\n * @notice End currently active promotion and send promotion tokens back to the creator.\n * @dev Will only send back tokens from the epochs that have not completed.\n * @param _promotionId Promotion id to end\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return true if operation was successful\n */\n function endPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Delete an inactive promotion and send promotion tokens back to the creator.\n * @dev Will send back all the tokens that have not been claimed yet by users.\n * @dev This function will revert if the promotion is still active.\n * @dev This function will revert if the grace period is not over yet.\n * @param _promotionId Promotion id to destroy\n * @param _to Address that will receive the remaining tokens if there are any left\n * @return True if operation was successful\n */\n function destroyPromotion(uint256 _promotionId, address _to) external returns (bool);\n\n /**\n * @notice Extend promotion by adding more epochs.\n * @param _promotionId Id of the promotion to extend\n * @param _numberOfEpochs Number of epochs to add\n * @return True if the operation was successful\n */\n function extendPromotion(uint256 _promotionId, uint8 _numberOfEpochs) external returns (bool);\n\n /**\n * @notice Claim rewards for a given promotion and epoch.\n * @dev Rewards can be claimed on behalf of a user.\n * @dev Rewards can only be claimed for a past epoch.\n * @param _user Address of the user to claim rewards for\n * @param _promotionId Id of the promotion to claim rewards for\n * @param _epochIds Epoch ids to claim rewards for\n * @return Total amount of rewards claimed\n */\n function claimRewards(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external returns (uint256);\n\n /**\n * @notice Get settings for a specific promotion.\n * @param _promotionId Id of the promotion to get settings for\n * @return Promotion settings\n */\n function getPromotion(uint256 _promotionId) external view returns (Promotion memory);\n\n /**\n * @notice Get the current epoch id of a promotion.\n * @dev Epoch ids and their boolean values are tightly packed and stored in a uint256, so epoch id starts at 0.\n * @param _promotionId Id of the promotion to get current epoch for\n * @return Current epoch id of the promotion\n */\n function getCurrentEpochId(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get the total amount of tokens left to be rewarded.\n * @param _promotionId Id of the promotion to get the total amount of tokens left to be rewarded for\n * @return Amount of tokens left to be rewarded\n */\n function getRemainingRewards(uint256 _promotionId) external view returns (uint256);\n\n /**\n * @notice Get amount of tokens to be rewarded for a given epoch.\n * @dev Rewards amount can only be retrieved for epochs that are over.\n * @dev Will revert if `_epochId` is over the total number of epochs or if epoch is not over.\n * @dev Will return 0 if the user average balance of tickets is 0.\n * @dev Will be 0 if user has already claimed rewards for the epoch.\n * @param _user Address of the user to get amount of rewards for\n * @param _promotionId Id of the promotion from which the epoch is\n * @param _epochIds Epoch ids to get reward amount for\n * @return Amount of tokens per epoch to be rewarded\n */\n function getRewardsAmount(\n address _user,\n uint256 _promotionId,\n uint8[] calldata _epochIds\n ) external view returns (uint256[] memory);\n}\n" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "@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" + }, + "contracts/PrizeTierHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"./interfaces/IPrizeTierHistory.sol\";\nimport \"./libraries/BinarySearchLib.sol\";\n\n/**\n * @title PoolTogether V4 PrizeTierHistory\n * @author PoolTogether Inc Team\n * @notice The PrizeTierHistory smart contract stores a history of PrizeTier structs linked to \n a range of valid Draw IDs. \n * @dev If the history param has single PrizeTier struct with a \"drawId\" of 1 all subsequent\n Draws will use that PrizeTier struct for PrizeDitribution calculations. The BinarySearchLib\n will find a PrizeTier using a \"atOrBefore\" range search when supplied drawId input parameter.\n */\ncontract PrizeTierHistory is IPrizeTierHistory, Manageable {\n\n // @dev The uint32[] type is extended with a binarySearch(uint32) function.\n using BinarySearchLib for uint32[];\n\n /**\n * @notice Ordered array of Draw IDs\n * @dev The history, with sequentially ordered ids, can be searched using binary search.\n The binary search will find index of a drawId (atOrBefore) using a specific drawId (at).\n When a new Draw ID is added to the history, a corresponding mapping of the ID is \n updated in the prizeTiers mapping.\n */\n uint32[] internal history;\n\n /**\n * @notice Mapping a Draw ID to a PrizeTier struct.\n * @dev The prizeTiers mapping links a Draw ID to a PrizeTier struct.\n The prizeTiers mapping is updated when a new Draw ID is added to the history.\n */\n mapping(uint32 => PrizeTier) internal prizeTiers;\n\n constructor(address owner) Ownable(owner) {}\n\n // @inheritdoc IPrizeTierHistory\n function count() external view override returns (uint256) {\n return history.length;\n }\n \n // @inheritdoc IPrizeTierHistory\n function getOldestDrawId() external view override returns (uint32) {\n return history[0];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getNewestDrawId() external view override returns (uint32) {\n return history[history.length - 1];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTier(uint32 drawId) override external view returns (PrizeTier memory) {\n require(drawId > 0, \"PrizeTierHistory/draw-id-not-zero\");\n return prizeTiers[history.binarySearch(drawId)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierList(uint32[] calldata _drawIds) override external view returns (PrizeTier[] memory) {\n uint256 _length = _drawIds.length; \n PrizeTier[] memory _data = new PrizeTier[](_length);\n for (uint256 index = 0; index < _length; index++) {\n _data[index] = prizeTiers[history.binarySearch(_drawIds[index])];\n }\n return _data;\n }\n\n // @inheritdoc IPrizeTierHistory\n function getPrizeTierAtIndex(uint256 index) external view override returns (PrizeTier memory) {\n return prizeTiers[uint32(index)];\n }\n\n // @inheritdoc IPrizeTierHistory\n function push(PrizeTier calldata nextPrizeTier) override external onlyManagerOrOwner {\n _push(nextPrizeTier);\n }\n \n // @inheritdoc IPrizeTierHistory\n function popAndPush(PrizeTier calldata newPrizeTier) override external onlyOwner returns (uint32) {\n uint length = history.length;\n require(length > 0, \"PrizeTierHistory/history-empty\");\n require(history[length - 1] == newPrizeTier.drawId, \"PrizeTierHistory/invalid-draw-id\");\n _replace(newPrizeTier);\n return newPrizeTier.drawId;\n }\n\n // @inheritdoc IPrizeTierHistory\n function replace(PrizeTier calldata newPrizeTier) override external onlyOwner {\n _replace(newPrizeTier);\n }\n\n function _push(PrizeTier memory _prizeTier) internal {\n uint32 _length = uint32(history.length);\n if (_length > 0) {\n uint32 _id = history[_length - 1];\n require(\n _prizeTier.drawId > _id,\n \"PrizeTierHistory/non-sequential-id\"\n );\n }\n history.push(_prizeTier.drawId);\n prizeTiers[_length] = _prizeTier;\n emit PrizeTierPushed(_prizeTier.drawId, _prizeTier);\n }\n\n function _replace(PrizeTier calldata _prizeTier) internal {\n uint256 cardinality = history.length;\n require(cardinality > 0, \"PrizeTierHistory/no-prize-tiers\");\n uint32 oldestDrawId = history[0];\n require(_prizeTier.drawId >= oldestDrawId, \"PrizeTierHistory/draw-id-out-of-range\");\n uint32 index = history.binarySearch(_prizeTier.drawId);\n require(history[index] == _prizeTier.drawId, \"PrizeTierHistory/draw-id-must-match\");\n prizeTiers[index] = _prizeTier;\n emit PrizeTierSet(_prizeTier.drawId, _prizeTier);\n }\n}\n" + }, + "contracts/libraries/BinarySearchLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\n\n/**\n * @title PoolTogether V4 BinarySearchLib\n * @author PoolTogether Inc Team\n * @notice BinarySearchLib uses binary search to find a parent contract struct with the drawId parameter\n * @dev The implementing contract must provider access to a struct (i.e. PrizeTier) list with is both\n * sorted and indexed by the drawId field for binary search to work.\n */\nlibrary BinarySearchLib {\n\n /**\n * @notice Find ID in array of ordered IDs using Binary Search.\n * @param _history uin32[] - Array of IDsq\n * @param _drawId uint32 - Draw ID to search for\n * @return uint32 - Index of ID in array\n */\n function binarySearch(uint32[] storage _history, uint32 _drawId) internal view returns (uint32) {\n uint32 index;\n uint32 leftSide = 0;\n uint32 rightSide = uint32(_history.length - 1);\n\n uint32 oldestDrawId = _history[0];\n uint32 newestDrawId = _history[rightSide];\n\n require(_drawId >= oldestDrawId, \"BinarySearchLib/draw-id-out-of-range\");\n if (_drawId >= newestDrawId) return rightSide;\n if (_drawId == oldestDrawId) return leftSide;\n\n while (true) {\n uint32 length = rightSide - leftSide;\n uint32 center = leftSide + (length / 2);\n uint32 centerID = _history[center];\n\n if (centerID == _drawId) {\n index = center;\n break;\n }\n\n if (length <= 1) {\n if(_history[rightSide] <= _drawId) {\n index = rightSide;\n } else {\n index = leftSide;\n }\n break;\n }\n \n if (centerID < _drawId) {\n leftSide = center;\n } else {\n rightSide = center - 1;\n }\n }\n\n return index;\n }\n}\n" + }, + "contracts/test/BinarySearchLibHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.6;\nimport \"../libraries/BinarySearchLib.sol\";\n\ncontract BinarySearchLibHarness {\n using BinarySearchLib for uint32[];\n uint32[] internal history;\n\n function getIndex(uint32 id) external view returns (uint32)\n {\n return history.binarySearch(id);\n }\n \n function getIndexes(uint32[] calldata ids) external view returns (uint32[] memory)\n {\n uint32[] memory data = new uint32[](ids.length);\n for (uint256 i = 0; i < ids.length; i++) {\n data[i] = history.binarySearch(ids[i]);\n }\n return data;\n }\n\n function set(uint32[] calldata _history) external\n {\n history = _history;\n }\n}\n" + }, + "contracts/PrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./interfaces/IPrizeFlush.sol\";\n\n/**\n * @title PoolTogether V4 PrizeFlush\n * @author PoolTogether Inc Team\n * @notice The PrizeFlush contract helps capture interest from the PrizePool and move collected funds\n to a designated PrizeDistributor contract. When deployed, the destination, reserve and strategy\n addresses are set and used as static parameters during every \"flush\" execution. The parameters can be\n reset by the Owner if necessary.\n */\ncontract PrizeFlush is IPrizeFlush, Manageable {\n /**\n * @notice Destination address for captured interest.\n * @dev Should be set to the PrizeDistributor address.\n */\n address internal destination;\n\n /// @notice Reserve address.\n IReserve internal reserve;\n\n /// @notice Strategy address.\n IStrategy internal strategy;\n\n /**\n * @notice Emitted when contract has been deployed.\n * @param destination Destination address\n * @param reserve Strategy address\n * @param strategy Reserve address\n *\n */\n event Deployed(\n address indexed destination,\n IReserve indexed reserve,\n IStrategy indexed strategy\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy Prize Flush.\n * @param _owner Prize Flush owner address\n * @param _destination Destination address\n * @param _strategy Strategy address\n * @param _reserve Reserve address\n *\n */\n constructor(\n address _owner,\n address _destination,\n IStrategy _strategy,\n IReserve _reserve\n ) Ownable(_owner) {\n _setDestination(_destination);\n _setReserve(_reserve);\n _setStrategy(_strategy);\n\n emit Deployed(_destination, _reserve, _strategy);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeFlush\n function getDestination() external view override returns (address) {\n return destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function getReserve() external view override returns (IReserve) {\n return reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function getStrategy() external view override returns (IStrategy) {\n return strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function setDestination(address _destination) external override onlyOwner returns (address) {\n _setDestination(_destination);\n emit DestinationSet(_destination);\n return _destination;\n }\n\n /// @inheritdoc IPrizeFlush\n function setReserve(IReserve _reserve) external override onlyOwner returns (IReserve) {\n _setReserve(_reserve);\n emit ReserveSet(_reserve);\n return _reserve;\n }\n\n /// @inheritdoc IPrizeFlush\n function setStrategy(IStrategy _strategy) external override onlyOwner returns (IStrategy) {\n _setStrategy(_strategy);\n emit StrategySet(_strategy);\n return _strategy;\n }\n\n /// @inheritdoc IPrizeFlush\n function flush() external override onlyManagerOrOwner returns (bool) {\n // Captures interest from PrizePool and distributes funds using a PrizeSplitStrategy.\n strategy.distribute();\n\n // After funds are distributed using PrizeSplitStrategy we EXPECT funds to be located in the Reserve.\n IReserve _reserve = reserve;\n IERC20 _token = _reserve.getToken();\n uint256 _amount = _token.balanceOf(address(_reserve));\n\n // IF the tokens were succesfully moved to the Reserve, now move them to the destination (PrizeDistributor) address.\n if (_amount > 0) {\n address _destination = destination;\n\n // Create checkpoint and transfers new total balance to PrizeDistributor\n _reserve.withdrawTo(_destination, _amount);\n\n emit Flushed(_destination, _amount);\n return true;\n }\n\n return false;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Set global destination variable.\n * @dev `_destination` cannot be the zero address.\n * @param _destination Destination address\n */\n function _setDestination(address _destination) internal {\n require(_destination != address(0), \"Flush/destination-not-zero-address\");\n destination = _destination;\n }\n\n /**\n * @notice Set global reserve variable.\n * @dev `_reserve` cannot be the zero address.\n * @param _reserve Reserve address\n */\n function _setReserve(IReserve _reserve) internal {\n require(address(_reserve) != address(0), \"Flush/reserve-not-zero-address\");\n reserve = _reserve;\n }\n\n /**\n * @notice Set global strategy variable.\n * @dev `_strategy` cannot be the zero address.\n * @param _strategy Strategy address\n */\n function _setStrategy(IStrategy _strategy) internal {\n require(address(_strategy) != address(0), \"Flush/strategy-not-zero-address\");\n strategy = _strategy;\n }\n}\n" + }, + "contracts/interfaces/IPrizeFlush.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IReserve.sol\";\nimport \"@pooltogether/v4-core/contracts/interfaces/IStrategy.sol\";\n\ninterface IPrizeFlush {\n /**\n * @notice Emit when the flush function has executed.\n * @param destination Address receiving funds\n * @param amount Amount of tokens transferred\n */\n event Flushed(address indexed destination, uint256 amount);\n\n /**\n * @notice Emit when destination is set.\n * @param destination Destination address\n */\n event DestinationSet(address destination);\n\n /**\n * @notice Emit when strategy is set.\n * @param strategy Strategy address\n */\n event StrategySet(IStrategy strategy);\n\n /**\n * @notice Emit when reserve is set.\n * @param reserve Reserve address\n */\n event ReserveSet(IReserve reserve);\n\n /// @notice Read global destination variable.\n function getDestination() external view returns (address);\n\n /// @notice Read global reserve variable.\n function getReserve() external view returns (IReserve);\n\n /// @notice Read global strategy variable.\n function getStrategy() external view returns (IStrategy);\n\n /// @notice Set global destination variable.\n function setDestination(address _destination) external returns (address);\n\n /// @notice Set global reserve variable.\n function setReserve(IReserve _reserve) external returns (IReserve);\n\n /// @notice Set global strategy variable.\n function setStrategy(IStrategy _strategy) external returns (IStrategy);\n\n /**\n * @notice Migrate interest from PrizePool to PrizeDistributor in a single transaction.\n * @dev Captures interest, checkpoint data and transfers tokens to final destination.\n * @return True if operation is successful.\n */\n function flush() external returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total depsosited\n * @param withdrawAccumulated Total withdrawn\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./PrizeSplit.sol\";\nimport \"../interfaces/IStrategy.sol\";\nimport \"../interfaces/IPrizePool.sol\";\n\n/**\n * @title PoolTogether V4 PrizeSplitStrategy\n * @author PoolTogether Inc Team\n * @notice Captures PrizePool interest for PrizeReserve and additional PrizeSplit recipients.\n The PrizeSplitStrategy will have at minimum a single PrizeSplit with 100% of the captured\n interest transfered to the PrizeReserve. Additional PrizeSplits can be added, depending on\n the deployers requirements (i.e. percentage to charity). In contrast to previous PoolTogether\n iterations, interest can be captured independent of a new Draw. Ideally (to save gas) interest\n is only captured when also distributing the captured prize(s) to applicable Prize Distributor(s).\n*/\ncontract PrizeSplitStrategy is PrizeSplit, IStrategy {\n /**\n * @notice PrizePool address\n */\n IPrizePool internal immutable prizePool;\n\n /**\n * @notice Deployed Event\n * @param owner Contract owner\n * @param prizePool Linked PrizePool contract\n */\n event Deployed(address indexed owner, IPrizePool prizePool);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Deploy the PrizeSplitStrategy smart contract.\n * @param _owner Owner address\n * @param _prizePool PrizePool address\n */\n constructor(address _owner, IPrizePool _prizePool) Ownable(_owner) {\n require(\n address(_prizePool) != address(0),\n \"PrizeSplitStrategy/prize-pool-not-zero-address\"\n );\n prizePool = _prizePool;\n emit Deployed(_owner, _prizePool);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IStrategy\n function distribute() external override returns (uint256) {\n uint256 prize = prizePool.captureAwardBalance();\n\n if (prize == 0) return 0;\n\n uint256 prizeRemaining = _distributePrizeSplits(prize);\n\n emit Distributed(prize - prizeRemaining);\n\n return prize;\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizePool() external view override returns (IPrizePool) {\n return prizePool;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Award ticket tokens to prize split recipient.\n * @dev Award ticket tokens to prize split recipient via the linked PrizePool contract.\n * @param _to Recipient of minted tokens.\n * @param _amount Amount of minted tokens.\n */\n function _awardPrizeSplitAmount(address _to, uint256 _amount) internal override {\n IControlledToken _ticket = prizePool.getTicket();\n prizePool.award(_to, _amount);\n emit PrizeSplitAwarded(_to, _amount, _ticket);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/prize-strategy/PrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../interfaces/IPrizeSplit.sol\";\n\n/**\n * @title PrizeSplit Interface\n * @author PoolTogether Inc Team\n */\nabstract contract PrizeSplit is IPrizeSplit, Ownable {\n /* ============ Global Variables ============ */\n PrizeSplitConfig[] internal _prizeSplits;\n\n uint16 public constant ONE_AS_FIXED_POINT_3 = 1000;\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplit(uint256 _prizeSplitIndex)\n external\n view\n override\n returns (PrizeSplitConfig memory)\n {\n return _prizeSplits[_prizeSplitIndex];\n }\n\n /// @inheritdoc IPrizeSplit\n function getPrizeSplits() external view override returns (PrizeSplitConfig[] memory) {\n return _prizeSplits;\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplits(PrizeSplitConfig[] calldata _newPrizeSplits)\n external\n override\n onlyOwner\n {\n uint256 newPrizeSplitsLength = _newPrizeSplits.length;\n require(newPrizeSplitsLength <= type(uint8).max, \"PrizeSplit/invalid-prizesplits-length\");\n\n // Add and/or update prize split configs using _newPrizeSplits PrizeSplitConfig structs array.\n for (uint256 index = 0; index < newPrizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _newPrizeSplits[index];\n\n // REVERT when setting the canonical burn address.\n require(split.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // IF the CURRENT prizeSplits length is below the NEW prizeSplits\n // PUSH the PrizeSplit struct to end of the list.\n if (_prizeSplits.length <= index) {\n _prizeSplits.push(split);\n } else {\n // ELSE update an existing PrizeSplit struct with new parameters\n PrizeSplitConfig memory currentSplit = _prizeSplits[index];\n\n // IF new PrizeSplit DOES NOT match the current PrizeSplit\n // WRITE to STORAGE with the new PrizeSplit\n if (\n split.target != currentSplit.target ||\n split.percentage != currentSplit.percentage\n ) {\n _prizeSplits[index] = split;\n } else {\n continue;\n }\n }\n\n // Emit the added/updated prize split config.\n emit PrizeSplitSet(split.target, split.percentage, index);\n }\n\n // Remove old prize splits configs. Match storage _prizesSplits.length with the passed newPrizeSplits.length\n while (_prizeSplits.length > newPrizeSplitsLength) {\n uint256 _index;\n unchecked {\n _index = _prizeSplits.length - 1;\n }\n _prizeSplits.pop();\n emit PrizeSplitRemoved(_index);\n }\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n }\n\n /// @inheritdoc IPrizeSplit\n function setPrizeSplit(PrizeSplitConfig memory _prizeSplit, uint8 _prizeSplitIndex)\n external\n override\n onlyOwner\n {\n require(_prizeSplitIndex < _prizeSplits.length, \"PrizeSplit/nonexistent-prizesplit\");\n require(_prizeSplit.target != address(0), \"PrizeSplit/invalid-prizesplit-target\");\n\n // Update the prize split config\n _prizeSplits[_prizeSplitIndex] = _prizeSplit;\n\n // Total prize split do not exceed 100%\n uint256 totalPercentage = _totalPrizeSplitPercentageAmount();\n require(totalPercentage <= ONE_AS_FIXED_POINT_3, \"PrizeSplit/invalid-prizesplit-percentage-total\");\n\n // Emit updated prize split config\n emit PrizeSplitSet(\n _prizeSplit.target,\n _prizeSplit.percentage,\n _prizeSplitIndex\n );\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Calculates total prize split percentage amount.\n * @dev Calculates total PrizeSplitConfig percentage(s) amount. Used to check the total does not exceed 100% of award distribution.\n * @return Total prize split(s) percentage amount\n */\n function _totalPrizeSplitPercentageAmount() internal view returns (uint256) {\n uint256 _tempTotalPercentage;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n _tempTotalPercentage += _prizeSplits[index].percentage;\n }\n\n return _tempTotalPercentage;\n }\n\n /**\n * @notice Distributes prize split(s).\n * @dev Distributes prize split(s) by awarding ticket or sponsorship tokens.\n * @param _prize Starting prize award amount\n * @return The remainder after splits are taken\n */\n function _distributePrizeSplits(uint256 _prize) internal returns (uint256) {\n uint256 _prizeTemp = _prize;\n uint256 prizeSplitsLength = _prizeSplits.length;\n\n for (uint256 index = 0; index < prizeSplitsLength; index++) {\n PrizeSplitConfig memory split = _prizeSplits[index];\n uint256 _splitAmount = (_prize * split.percentage) / 1000;\n\n // Award the prize split distribution amount.\n _awardPrizeSplitAmount(split.target, _splitAmount);\n\n // Update the remaining prize amount after distributing the prize split percentage.\n _prizeTemp -= _splitAmount;\n }\n\n return _prizeTemp;\n }\n\n /**\n * @notice Mints ticket or sponsorship tokens to prize split recipient.\n * @dev Mints ticket or sponsorship tokens to prize split recipient via the linked PrizePool contract.\n * @param _target Recipient of minted tokens\n * @param _amount Amount of minted tokens\n */\n function _awardPrizeSplitAmount(address _target, uint256 _amount) internal virtual;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/ITicket.sol\";\n\ninterface IPrizePool {\n /// @dev Event emitted when controlled token is added\n event ControlledTokenAdded(ITicket indexed token);\n\n event AwardCaptured(uint256 amount);\n\n /// @dev Event emitted when assets are deposited\n event Deposited(\n address indexed operator,\n address indexed to,\n ITicket indexed token,\n uint256 amount\n );\n\n /// @dev Event emitted when interest is awarded to a winner\n event Awarded(address indexed winner, ITicket indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are awarded to a winner\n event AwardedExternalERC20(address indexed winner, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC20s are transferred out\n event TransferredExternalERC20(address indexed to, address indexed token, uint256 amount);\n\n /// @dev Event emitted when external ERC721s are awarded to a winner\n event AwardedExternalERC721(address indexed winner, address indexed token, uint256[] tokenIds);\n\n /// @dev Event emitted when assets are withdrawn\n event Withdrawal(\n address indexed operator,\n address indexed from,\n ITicket indexed token,\n uint256 amount,\n uint256 redeemed\n );\n\n /// @dev Event emitted when the Balance Cap is set\n event BalanceCapSet(uint256 balanceCap);\n\n /// @dev Event emitted when the Liquidity Cap is set\n event LiquidityCapSet(uint256 liquidityCap);\n\n /// @dev Event emitted when the Prize Strategy is set\n event PrizeStrategySet(address indexed prizeStrategy);\n\n /// @dev Event emitted when the Ticket is set\n event TicketSet(ITicket indexed ticket);\n\n /// @dev Emitted when there was an error thrown awarding an External ERC721\n event ErrorAwardingExternalERC721(bytes error);\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n function depositTo(address to, uint256 amount) external;\n\n /// @notice Deposit assets into the Prize Pool in exchange for tokens,\n /// then sets the delegate on behalf of the caller.\n /// @param to The address receiving the newly minted tokens\n /// @param amount The amount of assets to deposit\n /// @param delegate The address to delegate to for the caller\n function depositToAndDelegate(address to, uint256 amount, address delegate) external;\n\n /// @notice Withdraw assets from the Prize Pool instantly.\n /// @param from The address to redeem tokens from.\n /// @param amount The amount of tokens to redeem for assets.\n /// @return The actual amount withdrawn\n function withdrawFrom(address from, uint256 amount) external returns (uint256);\n\n /// @notice Called by the prize strategy to award prizes.\n /// @dev The amount awarded must be less than the awardBalance()\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of assets to be awarded\n function award(address to, uint256 amount) external;\n\n /// @notice Returns the balance that is available to award.\n /// @dev captureAwardBalance() should be called first\n /// @return The total amount of assets to be awarded for the current prize\n function awardBalance() external view returns (uint256);\n\n /// @notice Captures any available interest as award balance.\n /// @dev This function also captures the reserve fees.\n /// @return The total amount of assets to be awarded for the current prize\n function captureAwardBalance() external returns (uint256);\n\n /// @dev Checks with the Prize Pool if a specific token type may be awarded as an external prize\n /// @param externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function canAwardExternal(address externalToken) external view returns (bool);\n\n // @dev Returns the total underlying balance of all assets. This includes both principal and interest.\n /// @return The underlying balance of assets\n function balance() external returns (uint256);\n\n /**\n * @notice Read internal Ticket accounted balance.\n * @return uint256 accountBalance\n */\n function getAccountedBalance() external view returns (uint256);\n\n /**\n * @notice Read internal balanceCap variable\n */\n function getBalanceCap() external view returns (uint256);\n\n /**\n * @notice Read internal liquidityCap variable\n */\n function getLiquidityCap() external view returns (uint256);\n\n /**\n * @notice Read ticket variable\n */\n function getTicket() external view returns (ITicket);\n\n /**\n * @notice Read token variable\n */\n function getToken() external view returns (address);\n\n /**\n * @notice Read prizeStrategy variable\n */\n function getPrizeStrategy() external view returns (address);\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function isControlled(ITicket controlledToken) external view returns (bool);\n\n /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens\n /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything.\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external asset token being awarded\n /// @param amount The amount of external assets to be awarded\n function transferExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the Prize-Strategy to award external ERC20 prizes\n /// @dev Used to award any arbitrary tokens held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param amount The amount of external assets to be awarded\n /// @param externalToken The address of the external asset token being awarded\n function awardExternalERC20(\n address to,\n address externalToken,\n uint256 amount\n ) external;\n\n /// @notice Called by the prize strategy to award external ERC721 prizes\n /// @dev Used to award any arbitrary NFTs held by the Prize Pool\n /// @param to The address of the winner that receives the award\n /// @param externalToken The address of the external NFT token being awarded\n /// @param tokenIds An array of NFT Token IDs to be transferred\n function awardExternalERC721(\n address to,\n address externalToken,\n uint256[] calldata tokenIds\n ) external;\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @dev If a user wins, his balance can go over the cap. He will be able to withdraw the excess but not deposit.\n /// @dev Needs to be called after deploying a prize pool to be able to deposit into it.\n /// @param balanceCap New balance cap.\n /// @return True if new balance cap has been successfully set.\n function setBalanceCap(uint256 balanceCap) external returns (bool);\n\n /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold\n /// @param liquidityCap The new liquidity cap for the prize pool\n function setLiquidityCap(uint256 liquidityCap) external;\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy.\n function setPrizeStrategy(address _prizeStrategy) external;\n\n /// @notice Set prize pool ticket.\n /// @param ticket Address of the ticket to set.\n /// @return True if ticket has been successfully set.\n function setTicket(ITicket ticket) external returns (bool);\n\n /// @notice Delegate the votes for a Compound COMP-like token held by the prize pool\n /// @param compLike The COMP-like token held by the prize pool that should be delegated\n /// @param to The address to delegate to\n function compLikeDelegate(ICompLike compLike, address to) external;\n}\n" + }, + "@pooltogether/v4-core/contracts/interfaces/IPrizeSplit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./IControlledToken.sol\";\nimport \"./IPrizePool.sol\";\n\n/**\n * @title Abstract prize split contract for adding unique award distribution to static addresses.\n * @author PoolTogether Inc Team\n */\ninterface IPrizeSplit {\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice The prize split configuration struct.\n * @dev The prize split configuration struct used to award prize splits during distribution.\n * @param target Address of recipient receiving the prize split distribution\n * @param percentage Percentage of prize split using a 0-1000 range for single decimal precision i.e. 125 = 12.5%\n */\n struct PrizeSplitConfig {\n address target;\n uint16 percentage;\n }\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is added or updated.\n * @dev Emitted when a PrizeSplitConfig config is added or updated in setPrizeSplits or setPrizeSplit.\n * @param target Address of prize split recipient\n * @param percentage Percentage of prize split. Must be between 0 and 1000 for single decimal precision\n * @param index Index of prize split in the prizeSplts array\n */\n event PrizeSplitSet(address indexed target, uint16 percentage, uint256 index);\n\n /**\n * @notice Emitted when a PrizeSplitConfig config is removed.\n * @dev Emitted when a PrizeSplitConfig config is removed from the prizeSplits array.\n * @param target Index of a previously active prize split config\n */\n event PrizeSplitRemoved(uint256 indexed target);\n\n /**\n * @notice Read prize split config from active PrizeSplits.\n * @dev Read PrizeSplitConfig struct from prizeSplits array.\n * @param prizeSplitIndex Index position of PrizeSplitConfig\n * @return PrizeSplitConfig Single prize split config\n */\n function getPrizeSplit(uint256 prizeSplitIndex) external view returns (PrizeSplitConfig memory);\n\n /**\n * @notice Read all prize splits configs.\n * @dev Read all PrizeSplitConfig structs stored in prizeSplits.\n * @return Array of PrizeSplitConfig structs\n */\n function getPrizeSplits() external view returns (PrizeSplitConfig[] memory);\n\n /**\n * @notice Get PrizePool address\n * @return IPrizePool\n */\n function getPrizePool() external view returns (IPrizePool);\n\n /**\n * @notice Set and remove prize split(s) configs. Only callable by owner.\n * @dev Set and remove prize split configs by passing a new PrizeSplitConfig structs array. Will remove existing PrizeSplitConfig(s) if passed array length is less than existing prizeSplits length.\n * @param newPrizeSplits Array of PrizeSplitConfig structs\n */\n function setPrizeSplits(PrizeSplitConfig[] calldata newPrizeSplits) external;\n\n /**\n * @notice Updates a previously set prize split config.\n * @dev Updates a prize split config by passing a new PrizeSplitConfig struct and current index position. Limited to contract owner.\n * @param prizeStrategySplit PrizeSplitConfig config struct\n * @param prizeSplitIndex Index position of PrizeSplitConfig to update\n */\n function setPrizeSplit(PrizeSplitConfig memory prizeStrategySplit, uint8 prizeSplitIndex)\n external;\n}\n" + }, + "@pooltogether/v4-core/contracts/external/compound/ICompLike.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ICompLike is IERC20 {\n function getCurrentVotes(address account) external view returns (uint96);\n\n function delegate(address delegate) external;\n}\n" + }, + "contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IControlledToken.sol\";\n\ninterface IStrategy {\n /**\n * @notice Emit when a strategy captures award amount from PrizePool.\n * @param totalPrizeCaptured Total prize captured from the PrizePool\n */\n event Distributed(uint256 totalPrizeCaptured);\n\n /**\n * @notice Emit when an individual prize split is awarded.\n * @param user User address being awarded\n * @param prizeAwarded Awarded prize amount\n * @param token Token address\n */\n event PrizeSplitAwarded(\n address indexed user,\n uint256 prizeAwarded,\n IControlledToken indexed token\n );\n\n /**\n * @notice Capture the award balance and distribute to prize splits.\n * @dev Permissionless function to initialize distribution of interst\n * @return Prize captured from PrizePool\n */\n function distribute() external returns (uint256);\n}\n" + }, + "@pooltogether/v4-core/contracts/ControlledToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\nimport \"./interfaces/IControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Controlled ERC20 Token\n * @author PoolTogether Inc Team\n * @notice ERC20 Tokens with a controller for minting & burning\n */\ncontract ControlledToken is ERC20Permit, IControlledToken {\n /* ============ Global Variables ============ */\n\n /// @notice Interface to the contract responsible for controlling mint/burn\n address public override immutable controller;\n\n /// @notice ERC20 controlled token decimals.\n uint8 private immutable _decimals;\n\n /* ============ Events ============ */\n\n /// @dev Emitted when contract is deployed\n event Deployed(string name, string symbol, uint8 decimals, address indexed controller);\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure that the caller is the controller contract\n modifier onlyController() {\n require(msg.sender == address(controller), \"ControlledToken/only-controller\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Controlled Token with Token Details and the Controller\n /// @param _name The name of the Token\n /// @param _symbol The symbol for the Token\n /// @param decimals_ The number of decimals for the Token\n /// @param _controller Address of the Controller contract for minting & burning\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ERC20Permit(\"PoolTogether ControlledToken\") ERC20(_name, _symbol) {\n require(address(_controller) != address(0), \"ControlledToken/controller-not-zero-address\");\n controller = _controller;\n\n require(decimals_ > 0, \"ControlledToken/decimals-gt-zero\");\n _decimals = decimals_;\n\n emit Deployed(_name, _symbol, decimals_, _controller);\n }\n\n /* ============ External Functions ============ */\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 function controllerMint(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _mint(_user, _amount);\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 function controllerBurn(address _user, uint256 _amount)\n external\n virtual\n override\n onlyController\n {\n _burn(_user, _amount);\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 function controllerBurnFrom(\n address _operator,\n address _user,\n uint256 _amount\n ) external virtual override onlyController {\n if (_operator != _user) {\n _approve(_user, _operator, allowance(_user, _operator) - _amount);\n }\n\n _burn(_user, _amount);\n }\n\n /// @notice Returns the ERC20 controlled token decimals.\n /// @dev This value should be equal to the decimals of the token used to deposit into the pool.\n /// @return uint8 decimals.\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\n require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender, _msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n uint256 senderBalance = _balances[sender];\n require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n _balances[recipient] += amount;\n\n emit Transfer(sender, recipient, amount);\n\n _afterTokenTransfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s;\n uint8 v;\n assembly {\n s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\n v := add(shr(255, vs), 27)\n }\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/**\n * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},\n * which have permission to mint (create) new tokens as they see fit.\n *\n * At construction, the deployer of the contract is the only minter.\n */\ncontract ERC20Mintable is ERC20 {\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}\n\n /**\n * @dev See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the {MinterRole}.\n */\n function mint(address account, uint256 amount) public {\n _mint(account, amount);\n }\n\n function burn(address account, uint256 amount) public returns (bool) {\n _burn(account, amount);\n return true;\n }\n\n function masterTransfer(\n address from,\n address to,\n uint256 amount\n ) public {\n _transfer(from, to, amount);\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../Reserve.sol\";\nimport \"./ERC20Mintable.sol\";\n\ncontract ReserveHarness is Reserve {\n constructor(address _owner, IERC20 _token) Reserve(_owner, _token) {}\n\n function setObservationsAt(ObservationLib.Observation[] calldata observations) external {\n for (uint256 i = 0; i < observations.length; i++) {\n reserveAccumulators[i] = observations[i];\n }\n\n nextIndex = uint24(observations.length);\n cardinality = uint24(observations.length);\n }\n\n function doubleCheckpoint(ERC20Mintable _token, uint256 _amount) external {\n _checkpoint();\n _token.mint(address(this), _amount);\n _checkpoint();\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/Reserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./interfaces/IReserve.sol\";\nimport \"./libraries/ObservationLib.sol\";\nimport \"./libraries/RingBufferLib.sol\";\n\n/**\n * @title PoolTogether V4 Reserve\n * @author PoolTogether Inc Team\n * @notice The Reserve contract provides historical lookups of a token balance increase during a target timerange.\n As the Reserve contract transfers OUT tokens, the withdraw accumulator is increased. When tokens are\n transfered IN new checkpoint *can* be created if checkpoint() is called after transfering tokens.\n By using the reserve and withdraw accumulators to create a new checkpoint, any contract or account\n can lookup the balance increase of the reserve for a target timerange. \n * @dev By calculating the total held tokens in a specific time range, contracts that require knowledge \n of captured interest during a draw period, can easily call into the Reserve and deterministically\n determine the newly aqcuired tokens for that time range. \n */\ncontract Reserve is IReserve, Manageable {\n using SafeERC20 for IERC20;\n\n /// @notice ERC20 token\n IERC20 public immutable token;\n\n /// @notice Total withdraw amount from reserve\n uint224 public withdrawAccumulator;\n uint32 private _gap;\n\n uint24 internal nextIndex;\n uint24 internal cardinality;\n\n /// @notice The maximum number of twab entries\n uint24 internal constant MAX_CARDINALITY = 16777215; // 2**24 - 1\n\n ObservationLib.Observation[MAX_CARDINALITY] internal reserveAccumulators;\n\n /* ============ Events ============ */\n\n event Deployed(IERC20 indexed token);\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _owner Owner address\n * @param _token ERC20 address\n */\n constructor(address _owner, IERC20 _token) Ownable(_owner) {\n token = _token;\n emit Deployed(_token);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IReserve\n function checkpoint() external override {\n _checkpoint();\n }\n\n /// @inheritdoc IReserve\n function getToken() external view override returns (IERC20) {\n return token;\n }\n\n /// @inheritdoc IReserve\n function getReserveAccumulatedBetween(uint32 _startTimestamp, uint32 _endTimestamp)\n external\n view\n override\n returns (uint224)\n {\n require(_startTimestamp < _endTimestamp, \"Reserve/start-less-then-end\");\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n\n (uint24 _newestIndex, ObservationLib.Observation memory _newestObservation) = _getNewestObservation(_nextIndex);\n (uint24 _oldestIndex, ObservationLib.Observation memory _oldestObservation) = _getOldestObservation(_nextIndex);\n\n uint224 _start = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _startTimestamp\n );\n\n uint224 _end = _getReserveAccumulatedAt(\n _newestObservation,\n _oldestObservation,\n _newestIndex,\n _oldestIndex,\n _cardinality,\n _endTimestamp\n );\n\n return _end - _start;\n }\n\n /// @inheritdoc IReserve\n function withdrawTo(address _recipient, uint256 _amount) external override onlyManagerOrOwner {\n _checkpoint();\n\n withdrawAccumulator += uint224(_amount);\n \n token.safeTransfer(_recipient, _amount);\n\n emit Withdrawn(_recipient, _amount);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Find optimal observation checkpoint using target timestamp\n * @dev Uses binary search if target timestamp is within ring buffer range.\n * @param _newestObservation ObservationLib.Observation\n * @param _oldestObservation ObservationLib.Observation\n * @param _newestIndex The index of the newest observation\n * @param _oldestIndex The index of the oldest observation\n * @param _cardinality RingBuffer Range\n * @param _timestamp Timestamp target\n *\n * @return Optimal reserveAccumlator for timestamp.\n */\n function _getReserveAccumulatedAt(\n ObservationLib.Observation memory _newestObservation,\n ObservationLib.Observation memory _oldestObservation,\n uint24 _newestIndex,\n uint24 _oldestIndex,\n uint24 _cardinality,\n uint32 _timestamp\n ) internal view returns (uint224) {\n uint32 timeNow = uint32(block.timestamp);\n\n // IF empty ring buffer exit early.\n if (_cardinality == 0) return 0;\n\n /**\n * Ring Buffer Search Optimization\n * Before performing binary search on the ring buffer check\n * to see if timestamp is within range of [o T n] by comparing\n * the target timestamp to the oldest/newest observation.timestamps\n * IF the timestamp is out of the ring buffer range avoid starting\n * a binary search, because we can return NULL or oldestObservation.amount\n */\n\n /**\n * IF oldestObservation.timestamp is after timestamp: T[old ]\n * the Reserve did NOT have a balance or the ring buffer\n * no longer contains that timestamp checkpoint.\n */\n if (_oldestObservation.timestamp > _timestamp) {\n return 0;\n }\n\n /**\n * IF newestObservation.timestamp is before timestamp: [ new]T\n * return _newestObservation.amount since observation\n * contains the highest checkpointed reserveAccumulator.\n */\n if (_newestObservation.timestamp <= _timestamp) {\n return _newestObservation.amount;\n }\n\n // IF the timestamp is witin range of ring buffer start/end: [new T old]\n // FIND the closest observation to the left(or exact) of timestamp: [OT ]\n (\n ObservationLib.Observation memory beforeOrAt,\n ObservationLib.Observation memory atOrAfter\n ) = ObservationLib.binarySearch(\n reserveAccumulators,\n _newestIndex,\n _oldestIndex,\n _timestamp,\n _cardinality,\n timeNow\n );\n\n // IF target timestamp is EXACT match for atOrAfter.timestamp observation return amount.\n // NOT having an exact match with atOrAfter means values will contain accumulator value AFTER the searchable range.\n // ELSE return observation.totalDepositedAccumulator closest to LEFT of target timestamp.\n if (atOrAfter.timestamp == _timestamp) {\n return atOrAfter.amount;\n } else {\n return beforeOrAt.amount;\n }\n }\n\n /// @notice Records the currently accrued reserve amount.\n function _checkpoint() internal {\n uint24 _cardinality = cardinality;\n uint24 _nextIndex = nextIndex;\n uint256 _balanceOfReserve = token.balanceOf(address(this));\n uint224 _withdrawAccumulator = withdrawAccumulator; //sload\n (uint24 newestIndex, ObservationLib.Observation memory newestObservation) = _getNewestObservation(_nextIndex);\n\n /**\n * IF tokens have been deposited into Reserve contract since the last checkpoint\n * create a new Reserve balance checkpoint. The will will update multiple times in a single block.\n */\n if (_balanceOfReserve + _withdrawAccumulator > newestObservation.amount) {\n uint32 nowTime = uint32(block.timestamp);\n\n // checkpointAccumulator = currentBalance + totalWithdraws\n uint224 newReserveAccumulator = uint224(_balanceOfReserve) + _withdrawAccumulator;\n\n // IF newestObservation IS NOT in the current block.\n // CREATE observation in the accumulators ring buffer.\n if (newestObservation.timestamp != nowTime) {\n reserveAccumulators[_nextIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n nextIndex = uint24(RingBufferLib.nextIndex(_nextIndex, MAX_CARDINALITY));\n if (_cardinality < MAX_CARDINALITY) {\n cardinality = _cardinality + 1;\n }\n }\n // ELSE IF newestObservation IS in the current block.\n // UPDATE the checkpoint previously created in block history.\n else {\n reserveAccumulators[newestIndex] = ObservationLib.Observation({\n amount: newReserveAccumulator,\n timestamp: nowTime\n });\n }\n\n emit Checkpoint(newReserveAccumulator, _withdrawAccumulator);\n }\n }\n\n /// @notice Retrieves the oldest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getOldestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = _nextIndex;\n observation = reserveAccumulators[index];\n\n // If the TWAB is not initialized we go to the beginning of the TWAB circular buffer at index 0\n if (observation.timestamp == 0) {\n index = 0;\n observation = reserveAccumulators[0];\n }\n }\n\n /// @notice Retrieves the newest observation\n /// @param _nextIndex The next index of the Reserve observations\n function _getNewestObservation(uint24 _nextIndex)\n internal\n view\n returns (uint24 index, ObservationLib.Observation memory observation)\n {\n index = uint24(RingBufferLib.newestIndex(_nextIndex, MAX_CARDINALITY));\n observation = reserveAccumulators[index];\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/libraries/DrawRingBufferLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"./RingBufferLib.sol\";\n\n/// @title Library for creating and managing a draw ring buffer.\nlibrary DrawRingBufferLib {\n /// @notice Draw buffer struct.\n struct Buffer {\n uint32 lastDrawId;\n uint32 nextIndex;\n uint32 cardinality;\n }\n\n /// @notice Helper function to know if the draw ring buffer has been initialized.\n /// @dev since draws start at 1 and are monotonically increased, we know we are uninitialized if nextIndex = 0 and lastDrawId = 0.\n /// @param _buffer The buffer to check.\n function isInitialized(Buffer memory _buffer) internal pure returns (bool) {\n return !(_buffer.nextIndex == 0 && _buffer.lastDrawId == 0);\n }\n\n /// @notice Push a draw to the buffer.\n /// @param _buffer The buffer to push to.\n /// @param _drawId The drawID to push.\n /// @return The new buffer.\n function push(Buffer memory _buffer, uint32 _drawId) internal pure returns (Buffer memory) {\n require(!isInitialized(_buffer) || _drawId == _buffer.lastDrawId + 1, \"DRB/must-be-contig\");\n\n return\n Buffer({\n lastDrawId: _drawId,\n nextIndex: uint32(RingBufferLib.nextIndex(_buffer.nextIndex, _buffer.cardinality)),\n cardinality: _buffer.cardinality\n });\n }\n\n /// @notice Get draw ring buffer index pointer.\n /// @param _buffer The buffer to get the `nextIndex` from.\n /// @param _drawId The draw id to get the index for.\n /// @return The draw ring buffer index pointer.\n function getIndex(Buffer memory _buffer, uint32 _drawId) internal pure returns (uint32) {\n require(isInitialized(_buffer) && _drawId <= _buffer.lastDrawId, \"DRB/future-draw\");\n\n uint32 indexOffset = _buffer.lastDrawId - _drawId;\n require(indexOffset < _buffer.cardinality, \"DRB/expired-draw\");\n\n uint256 mostRecent = RingBufferLib.newestIndex(_buffer.nextIndex, _buffer.cardinality);\n\n return uint32(RingBufferLib.offset(uint32(mostRecent), indexOffset, _buffer.cardinality));\n }\n}\n" + }, + "@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/owner-manager-contracts/contracts/Manageable.sol\";\n\nimport \"./libraries/DrawRingBufferLib.sol\";\nimport \"./interfaces/IPrizeDistributionBuffer.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionBuffer\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionBuffer contract provides historical lookups of PrizeDistribution struct parameters (linked with a Draw ID) via a\n circular ring buffer. Historical PrizeDistribution parameters can be accessed on-chain using a drawId to calculate\n ring buffer storage slot. The PrizeDistribution parameters can be created by manager/owner and existing PrizeDistribution\n parameters can only be updated the owner. When adding a new PrizeDistribution basic sanity checks will be used to\n validate the incoming parameters.\n*/\ncontract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable {\n using DrawRingBufferLib for DrawRingBufferLib.Buffer;\n\n /// @notice The maximum cardinality of the prize distribution ring buffer.\n /// @dev even with daily draws, 256 will give us over 8 months of history.\n uint256 internal constant MAX_CARDINALITY = 256;\n\n /// @notice The ceiling for prize distributions. 1e9 = 100%.\n /// @dev It's fixed point 9 because 1e9 is the largest \"1\" that fits into 2**32\n uint256 internal constant TIERS_CEILING = 1e9;\n\n /// @notice Emitted when the contract is deployed.\n /// @param cardinality The maximum number of records in the buffer before they begin to expire.\n event Deployed(uint8 cardinality);\n\n /// @notice PrizeDistribution ring buffer history.\n IPrizeDistributionBuffer.PrizeDistribution[MAX_CARDINALITY]\n internal prizeDistributionRingBuffer;\n\n /// @notice Ring buffer metadata (nextIndex, lastId, cardinality)\n DrawRingBufferLib.Buffer internal bufferMetadata;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionBuffer\n * @param _owner Address of the PrizeDistributionBuffer owner\n * @param _cardinality Cardinality of the `bufferMetadata`\n */\n constructor(address _owner, uint8 _cardinality) Ownable(_owner) {\n bufferMetadata.cardinality = _cardinality;\n emit Deployed(_cardinality);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getBufferCardinality() external view override returns (uint32) {\n return bufferMetadata.cardinality;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistribution(uint32 _drawId)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return _getPrizeDistribution(bufferMetadata, _drawId);\n }\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution[] memory)\n {\n uint256 drawIdsLength = _drawIds.length;\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n IPrizeDistributionBuffer.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionBuffer.PrizeDistribution[](\n drawIdsLength\n );\n\n for (uint256 i = 0; i < drawIdsLength; i++) {\n _prizeDistributions[i] = _getPrizeDistribution(buffer, _drawIds[i]);\n }\n\n return _prizeDistributions;\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getPrizeDistributionCount() external view override returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n if (buffer.lastDrawId == 0) {\n return 0;\n }\n\n uint32 bufferNextIndex = buffer.nextIndex;\n\n // If the buffer is full return the cardinality, else retun the nextIndex\n if (prizeDistributionRingBuffer[bufferNextIndex].matchCardinality != 0) {\n return buffer.cardinality;\n } else {\n return bufferNextIndex;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getNewestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n return (prizeDistributionRingBuffer[buffer.getIndex(buffer.lastDrawId)], buffer.lastDrawId);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function getOldestPrizeDistribution()\n external\n view\n override\n returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId)\n {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // if the ring buffer is full, the oldest is at the nextIndex\n prizeDistribution = prizeDistributionRingBuffer[buffer.nextIndex];\n\n // The PrizeDistribution at index 0 IS by default the oldest prizeDistribution.\n if (buffer.lastDrawId == 0) {\n drawId = 0; // return 0 to indicate no prizeDistribution ring buffer history\n } else if (prizeDistribution.bitRangeSize == 0) {\n // IF the next PrizeDistribution.bitRangeSize == 0 the ring buffer HAS NOT looped around so the oldest is the first entry.\n prizeDistribution = prizeDistributionRingBuffer[0];\n drawId = (buffer.lastDrawId + 1) - buffer.nextIndex;\n } else {\n // Calculates the drawId using the ring buffer cardinality\n // Sequential drawIds are gauranteed by DrawRingBufferLib.push()\n drawId = (buffer.lastDrawId + 1) - buffer.cardinality;\n }\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyManagerOrOwner returns (bool) {\n return _pushPrizeDistribution(_drawId, _prizeDistribution);\n }\n\n /// @inheritdoc IPrizeDistributionBuffer\n function setPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) external override onlyOwner returns (uint32) {\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n uint32 index = buffer.getIndex(_drawId);\n prizeDistributionRingBuffer[index] = _prizeDistribution;\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return _drawId;\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Gets the PrizeDistributionBuffer for a drawId\n * @param _buffer DrawRingBufferLib.Buffer\n * @param _drawId drawId\n */\n function _getPrizeDistribution(DrawRingBufferLib.Buffer memory _buffer, uint32 _drawId)\n internal\n view\n returns (IPrizeDistributionBuffer.PrizeDistribution memory)\n {\n return prizeDistributionRingBuffer[_buffer.getIndex(_drawId)];\n }\n\n /**\n * @notice Set newest PrizeDistributionBuffer in ring buffer storage.\n * @param _drawId drawId\n * @param _prizeDistribution PrizeDistributionBuffer struct\n */\n function _pushPrizeDistribution(\n uint32 _drawId,\n IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution\n ) internal returns (bool) {\n require(_drawId > 0, \"DrawCalc/draw-id-gt-0\");\n require(_prizeDistribution.matchCardinality > 0, \"DrawCalc/matchCardinality-gt-0\");\n require(\n _prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality,\n \"DrawCalc/bitRangeSize-too-large\"\n );\n\n require(_prizeDistribution.bitRangeSize > 0, \"DrawCalc/bitRangeSize-gt-0\");\n require(_prizeDistribution.maxPicksPerUser > 0, \"DrawCalc/maxPicksPerUser-gt-0\");\n require(_prizeDistribution.expiryDuration > 0, \"DrawCalc/expiryDuration-gt-0\");\n\n // ensure that the sum of the tiers are not gt 100%\n uint256 sumTotalTiers = 0;\n uint256 tiersLength = _prizeDistribution.tiers.length;\n\n for (uint256 index = 0; index < tiersLength; index++) {\n uint256 tier = _prizeDistribution.tiers[index];\n sumTotalTiers += tier;\n }\n\n // Each tier amount stored as uint32 - summed can't exceed 1e9\n require(sumTotalTiers <= TIERS_CEILING, \"DrawCalc/tiers-gt-100%\");\n\n DrawRingBufferLib.Buffer memory buffer = bufferMetadata;\n\n // store the PrizeDistribution in the ring buffer\n prizeDistributionRingBuffer[buffer.nextIndex] = _prizeDistribution;\n\n // update the ring buffer data\n bufferMetadata = buffer.push(_drawId);\n\n emit PrizeDistributionSet(_drawId, _prizeDistribution);\n\n return true;\n }\n}\n" + }, + "contracts/PrizeDistributionSplitter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@pooltogether/v4-core/contracts/interfaces/IPrizeDistributionSource.sol\";\n\n/**\n * @title PoolTogether V4 PrizeDistributionSplitter\n * @author PoolTogether Inc Team\n * @notice The PrizeDistributionSplitter contract allows us to deploy\n a second PrizeDistributionBuffer contract and point contracts that will call this one,\n to the correct PrizeDistributionBuffer contract.\n To do so, we set a `drawId` at which the second PrizeDistributionBuffer contract was deployed,\n when calling the `getPrizeDistributions` function with a `drawId` greater than or equal to the one set,\n we query the second PrizeDistributionBuffer contract, otherwise we query the first.\n */\ncontract PrizeDistributionSplitter is IPrizeDistributionSource {\n /// @notice DrawId at which the split occured\n uint32 public immutable drawId;\n\n /// @notice First PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceBefore;\n\n /// @notice Second PrizeDistributionBuffer source address\n IPrizeDistributionSource public immutable prizeDistributionSourceAtOrAfter;\n\n /* ============ Events ============ */\n\n /**\n * @notice Emitted when the drawId is set\n * @param drawId The drawId that was set\n */\n event DrawIdSet(uint32 drawId);\n\n /**\n * @notice Emitted when prize distribution sources are set\n * @param prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n event PrizeDistributionSourcesSet(\n IPrizeDistributionSource prizeDistributionSourceBefore,\n IPrizeDistributionSource prizeDistributionSourceAtOrAfter\n );\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructor for PrizeDistributionSource\n * @param _drawId DrawId at which the split occured\n * @param _prizeDistributionSourceBefore First PrizeDistributionBuffer contract address\n * @param _prizeDistributionSourceAtOrAfter Second PrizeDistributionBuffer contract address\n */\n constructor(\n uint32 _drawId,\n IPrizeDistributionSource _prizeDistributionSourceBefore,\n IPrizeDistributionSource _prizeDistributionSourceAtOrAfter\n ) {\n require(_drawId > 0, \"PrizeDistSplitter/drawId-gt-zero\");\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceBefore));\n _requirePrizeDistNotZeroAddress(address(_prizeDistributionSourceAtOrAfter));\n\n drawId = _drawId;\n prizeDistributionSourceBefore = _prizeDistributionSourceBefore;\n prizeDistributionSourceAtOrAfter = _prizeDistributionSourceAtOrAfter;\n\n emit DrawIdSet(_drawId);\n emit PrizeDistributionSourcesSet(\n _prizeDistributionSourceBefore,\n _prizeDistributionSourceAtOrAfter\n );\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizeDistributionSource\n function getPrizeDistributions(uint32[] calldata _drawIds)\n external\n view\n override\n returns (IPrizeDistributionSource.PrizeDistribution[] memory)\n {\n uint256 _drawIdsLength = _drawIds.length;\n uint32 _drawIdSplit = drawId;\n uint256 _atOrAfterIndex;\n\n for (_atOrAfterIndex; _atOrAfterIndex < _drawIdsLength; _atOrAfterIndex++) {\n if (_drawIds[_atOrAfterIndex] >= _drawIdSplit) {\n break;\n }\n }\n\n uint32[] memory _drawIdsBefore;\n uint32[] memory _drawIdsAtOrAfter;\n\n uint256 _drawIdsAtOrAfterLength = _drawIdsLength - _atOrAfterIndex;\n\n if (_atOrAfterIndex > 0) {\n _drawIdsBefore = new uint32[](_atOrAfterIndex);\n }\n\n if (_drawIdsAtOrAfterLength > 0) {\n _drawIdsAtOrAfter = new uint32[](_drawIdsAtOrAfterLength);\n }\n\n uint32 _previousDrawId;\n\n for (uint256 i; i < _drawIdsLength; i++) {\n uint32 _currentDrawId = _drawIds[i];\n require(_currentDrawId > _previousDrawId, \"PrizeDistSplitter/drawId-asc\");\n\n if (i < _atOrAfterIndex) {\n _drawIdsBefore[i] = _currentDrawId;\n } else {\n _drawIdsAtOrAfter[i - _atOrAfterIndex] = _currentDrawId;\n }\n\n _previousDrawId = _currentDrawId;\n }\n\n if (_drawIdsBefore.length == 0) {\n return prizeDistributionSourceAtOrAfter.getPrizeDistributions(_drawIdsAtOrAfter);\n } else if (_drawIdsAtOrAfter.length == 0) {\n return prizeDistributionSourceBefore.getPrizeDistributions(_drawIdsBefore);\n }\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsBefore = prizeDistributionSourceBefore.getPrizeDistributions(\n _drawIdsBefore\n );\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributionsAtOrAfter = prizeDistributionSourceAtOrAfter\n .getPrizeDistributions(_drawIdsAtOrAfter);\n\n IPrizeDistributionSource.PrizeDistribution[]\n memory _prizeDistributions = new IPrizeDistributionSource.PrizeDistribution[](\n _drawIdsLength\n );\n\n for (uint256 i = 0; i < _drawIdsLength; i++) {\n if (i < _atOrAfterIndex) {\n _prizeDistributions[i] = _prizeDistributionsBefore[i];\n } else {\n _prizeDistributions[i] = _prizeDistributionsAtOrAfter[i - _atOrAfterIndex];\n }\n }\n\n return _prizeDistributions;\n }\n\n /* ============ Require Functions ============ */\n\n /**\n * @notice Require that the given `_prizeDistributionSource` address is not the zero address\n * @param _prizeDistributionSource Address to check\n */\n function _requirePrizeDistNotZeroAddress(address _prizeDistributionSource) internal pure {\n require(_prizeDistributionSource != address(0), \"PrizeDistSplitter/not-zero-addr\");\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/PrizeDistributionBuffer.sol';\n" + }, + "@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/ExtendedSafeCastLib.sol\";\nimport \"./libraries/TwabLib.sol\";\nimport \"./interfaces/ITicket.sol\";\nimport \"./ControlledToken.sol\";\n\n/**\n * @title PoolTogether V4 Ticket\n * @author PoolTogether Inc Team\n * @notice The Ticket extends the standard ERC20 and ControlledToken interfaces with time-weighted average balance functionality.\n The average balance held by a user between two timestamps can be calculated, as well as the historic balance. The\n historic total supply is available as well as the average total supply between two timestamps.\n\n A user may \"delegate\" their balance; increasing another user's historic balance while retaining their tokens.\n*/\ncontract Ticket is ControlledToken, ITicket {\n using SafeERC20 for IERC20;\n using ExtendedSafeCastLib for uint256;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _DELEGATE_TYPEHASH =\n keccak256(\"Delegate(address user,address delegate,uint256 nonce,uint256 deadline)\");\n\n /// @notice Record of token holders TWABs for each account.\n mapping(address => TwabLib.Account) internal userTwabs;\n\n /// @notice Record of tickets total supply and ring buff parameters used for observation.\n TwabLib.Account internal totalSupplyTwab;\n\n /// @notice Mapping of delegates. Each address can delegate their ticket power to another.\n mapping(address => address) internal delegates;\n\n /* ============ Constructor ============ */\n\n /**\n * @notice Constructs Ticket with passed parameters.\n * @param _name ERC20 ticket token name.\n * @param _symbol ERC20 ticket token symbol.\n * @param decimals_ ERC20 ticket token decimals.\n * @param _controller ERC20 ticket controller address (ie: Prize Pool address).\n */\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) ControlledToken(_name, _symbol, decimals_, _controller) {}\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc ITicket\n function getAccountDetails(address _user)\n external\n view\n override\n returns (TwabLib.AccountDetails memory)\n {\n return userTwabs[_user].details;\n }\n\n /// @inheritdoc ITicket\n function getTwab(address _user, uint16 _index)\n external\n view\n override\n returns (ObservationLib.Observation memory)\n {\n return userTwabs[_user].twabs[_index];\n }\n\n /// @inheritdoc ITicket\n function getBalanceAt(address _user, uint64 _target) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(\n account.twabs,\n account.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getAverageBalancesBetween(\n address _user,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(userTwabs[_user], _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageTotalSuppliesBetween(\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) external view override returns (uint256[] memory) {\n return _getAverageBalancesBetween(totalSupplyTwab, _startTimes, _endTimes);\n }\n\n /// @inheritdoc ITicket\n function getAverageBalanceBetween(\n address _user,\n uint64 _startTime,\n uint64 _endTime\n ) external view override returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getBalancesAt(address _user, uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory _balances = new uint256[](length);\n\n TwabLib.Account storage twabContext = userTwabs[_user];\n TwabLib.AccountDetails memory details = twabContext.details;\n\n for (uint256 i = 0; i < length; i++) {\n _balances[i] = TwabLib.getBalanceAt(\n twabContext.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return _balances;\n }\n\n /// @inheritdoc ITicket\n function getTotalSupplyAt(uint64 _target) external view override returns (uint256) {\n return\n TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n totalSupplyTwab.details,\n uint32(_target),\n uint32(block.timestamp)\n );\n }\n\n /// @inheritdoc ITicket\n function getTotalSuppliesAt(uint64[] calldata _targets)\n external\n view\n override\n returns (uint256[] memory)\n {\n uint256 length = _targets.length;\n uint256[] memory totalSupplies = new uint256[](length);\n\n TwabLib.AccountDetails memory details = totalSupplyTwab.details;\n\n for (uint256 i = 0; i < length; i++) {\n totalSupplies[i] = TwabLib.getBalanceAt(\n totalSupplyTwab.twabs,\n details,\n uint32(_targets[i]),\n uint32(block.timestamp)\n );\n }\n\n return totalSupplies;\n }\n\n /// @inheritdoc ITicket\n function delegateOf(address _user) external view override returns (address) {\n return delegates[_user];\n }\n\n /// @inheritdoc ITicket\n function controllerDelegateFor(address _user, address _to) external override onlyController {\n _delegate(_user, _to);\n }\n\n /// @inheritdoc ITicket\n function delegateWithSignature(\n address _user,\n address _newDelegate,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external virtual override {\n require(block.timestamp <= _deadline, \"Ticket/delegate-expired-deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_DELEGATE_TYPEHASH, _user, _newDelegate, _useNonce(_user), _deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, _v, _r, _s);\n require(signer == _user, \"Ticket/delegate-invalid-signature\");\n\n _delegate(_user, _newDelegate);\n }\n\n /// @inheritdoc ITicket\n function delegate(address _to) external virtual override {\n _delegate(msg.sender, _to);\n }\n\n /// @notice Delegates a users chance to another\n /// @param _user The user whose balance should be delegated\n /// @param _to The delegate\n function _delegate(address _user, address _to) internal {\n uint256 balance = balanceOf(_user);\n address currentDelegate = delegates[_user];\n\n if (currentDelegate == _to) {\n return;\n }\n\n delegates[_user] = _to;\n\n _transferTwab(currentDelegate, _to, balance);\n\n emit Delegated(_user, _to);\n }\n\n /* ============ Internal Functions ============ */\n\n /**\n * @notice Retrieves the average balances held by a user for a given time frame.\n * @param _account 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 TwabLib.Account storage _account,\n uint64[] calldata _startTimes,\n uint64[] calldata _endTimes\n ) internal view returns (uint256[] memory) {\n uint256 startTimesLength = _startTimes.length;\n require(startTimesLength == _endTimes.length, \"Ticket/start-end-times-length-match\");\n\n TwabLib.AccountDetails memory accountDetails = _account.details;\n\n uint256[] memory averageBalances = new uint256[](startTimesLength);\n uint32 currentTimestamp = uint32(block.timestamp);\n\n for (uint256 i = 0; i < startTimesLength; i++) {\n averageBalances[i] = TwabLib.getAverageBalanceBetween(\n _account.twabs,\n accountDetails,\n uint32(_startTimes[i]),\n uint32(_endTimes[i]),\n currentTimestamp\n );\n }\n\n return averageBalances;\n }\n\n // @inheritdoc ERC20\n function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal override {\n if (_from == _to) {\n return;\n }\n\n address _fromDelegate;\n if (_from != address(0)) {\n _fromDelegate = delegates[_from];\n }\n\n address _toDelegate;\n if (_to != address(0)) {\n _toDelegate = delegates[_to];\n }\n\n _transferTwab(_fromDelegate, _toDelegate, _amount);\n }\n\n /// @notice Transfers the given TWAB balance from one user to another\n /// @param _from The user to transfer the balance from. May be zero in the event of a mint.\n /// @param _to The user to transfer the balance to. May be zero in the event of a burn.\n /// @param _amount The balance that is being transferred.\n function _transferTwab(address _from, address _to, uint256 _amount) internal {\n // If we are transferring tokens from a delegated account to an undelegated account\n if (_from != address(0)) {\n _decreaseUserTwab(_from, _amount);\n\n if (_to == address(0)) {\n _decreaseTotalSupplyTwab(_amount);\n }\n }\n\n // If we are transferring tokens from an undelegated account to a delegated account\n if (_to != address(0)) {\n _increaseUserTwab(_to, _amount);\n\n if (_from == address(0)) {\n _increaseTotalSupplyTwab(_amount);\n }\n }\n }\n\n /**\n * @notice Increase `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _increaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.increaseBalance(_account, _amount.toUint208(), uint32(block.timestamp));\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /**\n * @notice Decrease `_to` TWAB balance.\n * @param _to Address of the delegate.\n * @param _amount Amount of tokens to be added to `_to` TWAB balance.\n */\n function _decreaseUserTwab(\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n TwabLib.Account storage _account = userTwabs[_to];\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory twab,\n bool isNew\n ) = TwabLib.decreaseBalance(\n _account,\n _amount.toUint208(),\n \"Ticket/twab-burn-lt-balance\",\n uint32(block.timestamp)\n );\n\n _account.details = accountDetails;\n\n if (isNew) {\n emit NewUserTwab(_to, twab);\n }\n }\n\n /// @notice Decreases the total supply twab. Should be called anytime a balance moves from delegated to undelegated\n /// @param _amount The amount to decrease the total by\n function _decreaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory tsTwab,\n bool tsIsNew\n ) = TwabLib.decreaseBalance(\n totalSupplyTwab,\n _amount.toUint208(),\n \"Ticket/burn-amount-exceeds-total-supply-twab\",\n uint32(block.timestamp)\n );\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(tsTwab);\n }\n }\n\n /// @notice Increases the total supply twab. Should be called anytime a balance moves from undelegated to delegated\n /// @param _amount The amount to increase the total by\n function _increaseTotalSupplyTwab(uint256 _amount) internal {\n if (_amount == 0) {\n return;\n }\n\n (\n TwabLib.AccountDetails memory accountDetails,\n ObservationLib.Observation memory _totalSupply,\n bool tsIsNew\n ) = TwabLib.increaseBalance(totalSupplyTwab, _amount.toUint208(), uint32(block.timestamp));\n\n totalSupplyTwab.details = accountDetails;\n\n if (tsIsNew) {\n emit NewTotalSupplyTwab(_totalSupply);\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/Ticket.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/Ticket.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/PrizePool.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/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@pooltogether/owner-manager-contracts/contracts/Ownable.sol\";\n\nimport \"../external/compound/ICompLike.sol\";\nimport \"../interfaces/IPrizePool.sol\";\nimport \"../interfaces/ITicket.sol\";\n\n/**\n * @title PoolTogether V4 PrizePool\n * @author PoolTogether Inc Team\n * @notice Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy.\n Users deposit and withdraw from this contract to participate in Prize Pool.\n Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract.\n Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens\n*/\nabstract contract PrizePool is IPrizePool, Ownable, ReentrancyGuard, IERC721Receiver {\n using SafeCast for uint256;\n using SafeERC20 for IERC20;\n using ERC165Checker for address;\n\n /// @notice Semver Version\n string public constant VERSION = \"4.0.0\";\n\n /// @notice Prize Pool ticket. Can only be set once by calling `setTicket()`.\n ITicket internal ticket;\n\n /// @notice The Prize Strategy that this Prize Pool is bound to.\n address internal prizeStrategy;\n\n /// @notice The total amount of tickets a user can hold.\n uint256 internal balanceCap;\n\n /// @notice The total amount of funds that the prize pool can hold.\n uint256 internal liquidityCap;\n\n /// @notice the The awardable balance\n uint256 internal _currentAwardBalance;\n\n /* ============ Modifiers ============ */\n\n /// @dev Function modifier to ensure caller is the prize-strategy\n modifier onlyPrizeStrategy() {\n require(msg.sender == prizeStrategy, \"PrizePool/only-prizeStrategy\");\n _;\n }\n\n /// @dev Function modifier to ensure the deposit amount does not exceed the liquidity cap (if set)\n modifier canAddLiquidity(uint256 _amount) {\n require(_canAddLiquidity(_amount), \"PrizePool/exceeds-liquidity-cap\");\n _;\n }\n\n /* ============ Constructor ============ */\n\n /// @notice Deploy the Prize Pool\n /// @param _owner Address of the Prize Pool owner\n constructor(address _owner) Ownable(_owner) ReentrancyGuard() {\n _setLiquidityCap(type(uint256).max);\n }\n\n /* ============ External Functions ============ */\n\n /// @inheritdoc IPrizePool\n function balance() external override returns (uint256) {\n return _balance();\n }\n\n /// @inheritdoc IPrizePool\n function awardBalance() external view override returns (uint256) {\n return _currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function canAwardExternal(address _externalToken) external view override returns (bool) {\n return _canAwardExternal(_externalToken);\n }\n\n /// @inheritdoc IPrizePool\n function isControlled(ITicket _controlledToken) external view override returns (bool) {\n return _isControlled(_controlledToken);\n }\n\n /// @inheritdoc IPrizePool\n function getAccountedBalance() external view override returns (uint256) {\n return _ticketTotalSupply();\n }\n\n /// @inheritdoc IPrizePool\n function getBalanceCap() external view override returns (uint256) {\n return balanceCap;\n }\n\n /// @inheritdoc IPrizePool\n function getLiquidityCap() external view override returns (uint256) {\n return liquidityCap;\n }\n\n /// @inheritdoc IPrizePool\n function getTicket() external view override returns (ITicket) {\n return ticket;\n }\n\n /// @inheritdoc IPrizePool\n function getPrizeStrategy() external view override returns (address) {\n return prizeStrategy;\n }\n\n /// @inheritdoc IPrizePool\n function getToken() external view override returns (address) {\n return address(_token());\n }\n\n /// @inheritdoc IPrizePool\n function captureAwardBalance() external override nonReentrant returns (uint256) {\n uint256 ticketTotalSupply = _ticketTotalSupply();\n uint256 currentAwardBalance = _currentAwardBalance;\n\n // it's possible for the balance to be slightly less due to rounding errors in the underlying yield source\n uint256 currentBalance = _balance();\n uint256 totalInterest = (currentBalance > ticketTotalSupply)\n ? currentBalance - ticketTotalSupply\n : 0;\n\n uint256 unaccountedPrizeBalance = (totalInterest > currentAwardBalance)\n ? totalInterest - currentAwardBalance\n : 0;\n\n if (unaccountedPrizeBalance > 0) {\n currentAwardBalance = totalInterest;\n _currentAwardBalance = currentAwardBalance;\n\n emit AwardCaptured(unaccountedPrizeBalance);\n }\n\n return currentAwardBalance;\n }\n\n /// @inheritdoc IPrizePool\n function depositTo(address _to, uint256 _amount)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function depositToAndDelegate(address _to, uint256 _amount, address _delegate)\n external\n override\n nonReentrant\n canAddLiquidity(_amount)\n {\n _depositTo(msg.sender, _to, _amount);\n ticket.controllerDelegateFor(msg.sender, _delegate);\n }\n\n /// @notice Transfers tokens in from one user and mints tickets to another\n /// @notice _operator The user to transfer tokens from\n /// @notice _to The user to mint tickets to\n /// @notice _amount The amount to transfer and mint\n function _depositTo(address _operator, address _to, uint256 _amount) internal\n {\n require(_canDeposit(_to, _amount), \"PrizePool/exceeds-balance-cap\");\n\n ITicket _ticket = ticket;\n\n _token().safeTransferFrom(_operator, address(this), _amount);\n\n _mint(_to, _amount, _ticket);\n _supply(_amount);\n\n emit Deposited(_operator, _to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function withdrawFrom(address _from, uint256 _amount)\n external\n override\n nonReentrant\n returns (uint256)\n {\n ITicket _ticket = ticket;\n\n // burn the tickets\n _ticket.controllerBurnFrom(msg.sender, _from, _amount);\n\n // redeem the tickets\n uint256 _redeemed = _redeem(_amount);\n\n _token().safeTransfer(_from, _redeemed);\n\n emit Withdrawal(msg.sender, _from, _ticket, _amount, _redeemed);\n\n return _redeemed;\n }\n\n /// @inheritdoc IPrizePool\n function award(address _to, uint256 _amount) external override onlyPrizeStrategy {\n if (_amount == 0) {\n return;\n }\n\n uint256 currentAwardBalance = _currentAwardBalance;\n\n require(_amount <= currentAwardBalance, \"PrizePool/award-exceeds-avail\");\n\n unchecked {\n _currentAwardBalance = currentAwardBalance - _amount;\n }\n\n ITicket _ticket = ticket;\n\n _mint(_to, _amount, _ticket);\n\n emit Awarded(_to, _ticket, _amount);\n }\n\n /// @inheritdoc IPrizePool\n function transferExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit TransferredExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC20(\n address _to,\n address _externalToken,\n uint256 _amount\n ) external override onlyPrizeStrategy {\n if (_transferOut(_to, _externalToken, _amount)) {\n emit AwardedExternalERC20(_to, _externalToken, _amount);\n }\n }\n\n /// @inheritdoc IPrizePool\n function awardExternalERC721(\n address _to,\n address _externalToken,\n uint256[] calldata _tokenIds\n ) external override onlyPrizeStrategy {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_tokenIds.length == 0) {\n return;\n }\n\n uint256[] memory _awardedTokenIds = new uint256[](_tokenIds.length); \n bool hasAwardedTokenIds;\n\n for (uint256 i = 0; i < _tokenIds.length; i++) {\n try IERC721(_externalToken).safeTransferFrom(address(this), _to, _tokenIds[i]) {\n hasAwardedTokenIds = true;\n _awardedTokenIds[i] = _tokenIds[i];\n } catch (\n bytes memory error\n ) {\n emit ErrorAwardingExternalERC721(error);\n }\n }\n if (hasAwardedTokenIds) { \n emit AwardedExternalERC721(_to, _externalToken, _awardedTokenIds);\n }\n }\n\n /// @inheritdoc IPrizePool\n function setBalanceCap(uint256 _balanceCap) external override onlyOwner returns (bool) {\n _setBalanceCap(_balanceCap);\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner {\n _setLiquidityCap(_liquidityCap);\n }\n\n /// @inheritdoc IPrizePool\n function setTicket(ITicket _ticket) external override onlyOwner returns (bool) {\n require(address(_ticket) != address(0), \"PrizePool/ticket-not-zero-address\");\n require(address(ticket) == address(0), \"PrizePool/ticket-already-set\");\n\n ticket = _ticket;\n\n emit TicketSet(_ticket);\n\n _setBalanceCap(type(uint256).max);\n\n return true;\n }\n\n /// @inheritdoc IPrizePool\n function setPrizeStrategy(address _prizeStrategy) external override onlyOwner {\n _setPrizeStrategy(_prizeStrategy);\n }\n\n /// @inheritdoc IPrizePool\n function compLikeDelegate(ICompLike _compLike, address _to) external override onlyOwner {\n if (_compLike.balanceOf(address(this)) > 0) {\n _compLike.delegate(_to);\n }\n }\n\n /// @inheritdoc IERC721Receiver\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n /* ============ Internal Functions ============ */\n\n /// @notice Transfer out `amount` of `externalToken` to recipient `to`\n /// @dev Only awardable `externalToken` can be transferred out\n /// @param _to Recipient address\n /// @param _externalToken Address of the external asset token being transferred\n /// @param _amount Amount of external assets to be transferred\n /// @return True if transfer is successful\n function _transferOut(\n address _to,\n address _externalToken,\n uint256 _amount\n ) internal returns (bool) {\n require(_canAwardExternal(_externalToken), \"PrizePool/invalid-external-token\");\n\n if (_amount == 0) {\n return false;\n }\n\n IERC20(_externalToken).safeTransfer(_to, _amount);\n\n return true;\n }\n\n /// @notice Called to mint controlled tokens. Ensures that token listener callbacks are fired.\n /// @param _to The user who is receiving the tokens\n /// @param _amount The amount of tokens they are receiving\n /// @param _controlledToken The token that is going to be minted\n function _mint(\n address _to,\n uint256 _amount,\n ITicket _controlledToken\n ) internal {\n _controlledToken.controllerMint(_to, _amount);\n }\n\n /// @dev Checks if `user` can deposit in the Prize Pool based on the current balance cap.\n /// @param _user Address of the user depositing.\n /// @param _amount The amount of tokens to be deposited into the Prize Pool.\n /// @return True if the Prize Pool can receive the specified `amount` of tokens.\n function _canDeposit(address _user, uint256 _amount) internal view returns (bool) {\n uint256 _balanceCap = balanceCap;\n\n if (_balanceCap == type(uint256).max) return true;\n\n return (ticket.balanceOf(_user) + _amount <= _balanceCap);\n }\n\n /// @dev Checks if the Prize Pool can receive liquidity based on the current cap\n /// @param _amount The amount of liquidity to be added to the Prize Pool\n /// @return True if the Prize Pool can receive the specified amount of liquidity\n function _canAddLiquidity(uint256 _amount) internal view returns (bool) {\n uint256 _liquidityCap = liquidityCap;\n if (_liquidityCap == type(uint256).max) return true;\n return (_ticketTotalSupply() + _amount <= _liquidityCap);\n }\n\n /// @dev Checks if a specific token is controlled by the Prize Pool\n /// @param _controlledToken The address of the token to check\n /// @return True if the token is a controlled token, false otherwise\n function _isControlled(ITicket _controlledToken) internal view returns (bool) {\n return (ticket == _controlledToken);\n }\n\n /// @notice Allows the owner to set a balance cap per `token` for the pool.\n /// @param _balanceCap New balance cap.\n function _setBalanceCap(uint256 _balanceCap) internal {\n balanceCap = _balanceCap;\n emit BalanceCapSet(_balanceCap);\n }\n\n /// @notice Allows the owner to set a liquidity cap for the pool\n /// @param _liquidityCap New liquidity cap\n function _setLiquidityCap(uint256 _liquidityCap) internal {\n liquidityCap = _liquidityCap;\n emit LiquidityCapSet(_liquidityCap);\n }\n\n /// @notice Sets the prize strategy of the prize pool. Only callable by the owner.\n /// @param _prizeStrategy The new prize strategy\n function _setPrizeStrategy(address _prizeStrategy) internal {\n require(_prizeStrategy != address(0), \"PrizePool/prizeStrategy-not-zero\");\n\n prizeStrategy = _prizeStrategy;\n\n emit PrizeStrategySet(_prizeStrategy);\n }\n\n /// @notice The current total of tickets.\n /// @return Ticket total supply.\n function _ticketTotalSupply() internal view returns (uint256) {\n return ticket.totalSupply();\n }\n\n /// @dev Gets the current time as represented by the current block\n /// @return The timestamp of the current block\n function _currentTime() internal view virtual returns (uint256) {\n return block.timestamp;\n }\n\n /* ============ Abstract Contract Implementatiton ============ */\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view virtual returns (bool);\n\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token\n function _token() internal view virtual returns (IERC20);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal virtual returns (uint256);\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal virtual;\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal virtual returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface,\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n _supportsERC165Interface(account, type(IERC165).interfaceId) &&\n !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)\n internal\n view\n returns (bool[] memory)\n {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in _interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!_supportsERC165Interface(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n * Interface identification is specified in ERC-165.\n */\n function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);\n if (result.length < 32) return false;\n return success && abi.decode(result, (bool));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"../Ticket.sol\";\n\ncontract TicketHarness is Ticket {\n using SafeCast for uint256;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 decimals_,\n address _controller\n ) Ticket(_name, _symbol, decimals_, _controller) {}\n\n function flashLoan(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _burn(_to, _amount);\n }\n\n function burn(address _from, uint256 _amount) external {\n _burn(_from, _amount);\n }\n\n function mint(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n }\n\n function mintTwice(address _to, uint256 _amount) external {\n _mint(_to, _amount);\n _mint(_to, _amount);\n }\n\n /// @dev we need to use a different function name than `transfer`\n /// otherwise it collides with the `transfer` function of the `ERC20` contract\n function transferTo(\n address _sender,\n address _recipient,\n uint256 _amount\n ) external {\n _transfer(_sender, _recipient, _amount);\n }\n\n function getBalanceTx(address _user, uint32 _target) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getBalanceAt(account.twabs, account.details, _target, uint32(block.timestamp));\n }\n\n function getAverageBalanceTx(\n address _user,\n uint32 _startTime,\n uint32 _endTime\n ) external view returns (uint256) {\n TwabLib.Account storage account = userTwabs[_user];\n\n return\n TwabLib.getAverageBalanceBetween(\n account.twabs,\n account.details,\n uint32(_startTime),\n uint32(_endTime),\n uint32(block.timestamp)\n );\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/TicketHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/TicketHarness.sol';\n" + }, + "@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@pooltogether/yield-source-interface/contracts/IYieldSource.sol\";\n\nimport \"./PrizePool.sol\";\n\n/**\n * @title PoolTogether V4 YieldSourcePrizePool\n * @author PoolTogether Inc Team\n * @notice The Yield Source Prize Pool uses a yield source contract to generate prizes.\n * Funds that are deposited into the prize pool are then deposited into a yield source. (i.e. Aave, Compound, etc...)\n */\ncontract YieldSourcePrizePool is PrizePool {\n using SafeERC20 for IERC20;\n using Address for address;\n\n /// @notice Address of the yield source.\n IYieldSource public immutable yieldSource;\n\n /// @dev Emitted when yield source prize pool is deployed.\n /// @param yieldSource Address of the yield source.\n event Deployed(address indexed yieldSource);\n\n /// @notice Emitted when stray deposit token balance in this contract is swept\n /// @param amount The amount that was swept\n event Swept(uint256 amount);\n\n /// @notice Deploy the Prize Pool and Yield Service with the required contract connections\n /// @param _owner Address of the Yield Source Prize Pool owner\n /// @param _yieldSource Address of the yield source\n constructor(address _owner, IYieldSource _yieldSource) PrizePool(_owner) {\n require(\n address(_yieldSource) != address(0),\n \"YieldSourcePrizePool/yield-source-not-zero-address\"\n );\n\n yieldSource = _yieldSource;\n\n // A hack to determine whether it's an actual yield source\n (bool succeeded, bytes memory data) = address(_yieldSource).staticcall(\n abi.encodePacked(_yieldSource.depositToken.selector)\n );\n address resultingAddress;\n if (data.length > 0) {\n resultingAddress = abi.decode(data, (address));\n }\n require(succeeded && resultingAddress != address(0), \"YieldSourcePrizePool/invalid-yield-source\");\n\n emit Deployed(address(_yieldSource));\n }\n\n /// @notice Sweeps any stray balance of deposit tokens into the yield source.\n /// @dev This becomes prize money\n function sweep() external nonReentrant onlyOwner {\n uint256 balance = _token().balanceOf(address(this));\n _supply(balance);\n\n emit Swept(balance);\n }\n\n /// @notice Determines whether the passed token can be transferred out as an external award.\n /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The\n /// prize strategy should not be allowed to move those tokens.\n /// @param _externalToken The address of the token to check\n /// @return True if the token may be awarded, false otherwise\n function _canAwardExternal(address _externalToken) internal view override returns (bool) {\n IYieldSource _yieldSource = yieldSource;\n return (\n _externalToken != address(_yieldSource) &&\n _externalToken != _yieldSource.depositToken()\n );\n }\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens\n function _balance() internal override returns (uint256) {\n return yieldSource.balanceOfToken(address(this));\n }\n\n /// @notice Returns the address of the ERC20 asset token used for deposits.\n /// @return Address of the ERC20 asset token.\n function _token() internal view override returns (IERC20) {\n return IERC20(yieldSource.depositToken());\n }\n\n /// @notice Supplies asset tokens to the yield source.\n /// @param _mintAmount The amount of asset tokens to be supplied\n function _supply(uint256 _mintAmount) internal override {\n _token().safeIncreaseAllowance(address(yieldSource), _mintAmount);\n yieldSource.supplyTokenTo(_mintAmount, address(this));\n }\n\n /// @notice Redeems asset tokens from the yield source.\n /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed\n /// @return The actual amount of tokens that were redeemed.\n function _redeem(uint256 _redeemAmount) internal override returns (uint256) {\n return yieldSource.redeemToken(_redeemAmount);\n }\n}\n" + }, + "@pooltogether/yield-source-interface/contracts/IYieldSource.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.6.0;\n\n/// @title Defines the functions used to interact with a yield source. The Prize Pool inherits this contract.\n/// @notice Prize Pools subclasses need to implement this interface so that yield can be generated.\ninterface IYieldSource {\n /// @notice Returns the ERC20 asset token used for deposits.\n /// @return The ERC20 asset token address.\n function depositToken() external view returns (address);\n\n /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.\n /// @return The underlying balance of asset tokens.\n function balanceOfToken(address addr) external returns (uint256);\n\n /// @notice Supplies tokens to the yield source. Allows assets to be supplied on other user's behalf using the `to` param.\n /// @param amount The amount of asset tokens to be supplied. Denominated in `depositToken()` as above.\n /// @param to The user whose balance will receive the tokens\n function supplyTokenTo(uint256 amount, address to) external;\n\n /// @notice Redeems tokens from the yield source.\n /// @param amount The amount of asset tokens to withdraw. Denominated in `depositToken()` as above.\n /// @return The actual amount of interst bearing tokens that were redeemed.\n function redeemToken(uint256 amount) external returns (uint256);\n}\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-pool/YieldSourcePrizePool.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IReserve.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ReserveHarness.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ReserveHarness.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/test/ERC20Mintable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/test/ERC20Mintable.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/prize-strategy/PrizeSplitStrategy.sol';\n" + }, + "contracts/hardhat-dependency-compiler/@pooltogether/v4-core/contracts/interfaces/IStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@pooltogether/v4-core/contracts/interfaces/IStrategy.sol';\n" + }, + "contracts/test/TwabRewardsHarness.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"../TwabRewards.sol\";\n\ncontract TwabRewardsHarness is TwabRewards {\n constructor(ITicket _ticket) TwabRewards(_ticket) {}\n\n function requireTicket(ITicket _ticket) external view {\n return _requireTicket(_ticket);\n }\n\n function isClaimedEpoch(uint256 _userClaimedEpochs, uint8 _epochId)\n external\n pure\n returns (bool)\n {\n return _isClaimedEpoch(_userClaimedEpochs, _epochId);\n }\n}\n" + }, + "contracts/interfaces/IReserve.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.6;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IReserve {\n /**\n * @notice Emit when checkpoint is created.\n * @param reserveAccumulated Total amount of tokens transferred to the reserve.\n * @param withdrawAccumulated Total amount of tokens withdrawn from the reserve.\n */\n\n event Checkpoint(uint256 reserveAccumulated, uint256 withdrawAccumulated);\n /**\n * @notice Emit when the withdrawTo function has executed.\n * @param recipient Address receiving funds\n * @param amount Amount of tokens transfered.\n */\n event Withdrawn(address indexed recipient, uint256 amount);\n\n /**\n * @notice Create observation checkpoint in ring bufferr.\n * @dev Calculates total desposited tokens since last checkpoint and creates new accumulator checkpoint.\n */\n function checkpoint() external;\n\n /**\n * @notice Read global token value.\n * @return IERC20\n */\n function getToken() external view returns (IERC20);\n\n /**\n * @notice Calculate token accumulation beween timestamp range.\n * @dev Search the ring buffer for two checkpoint observations and diffs accumulator amount.\n * @param startTimestamp Account address\n * @param endTimestamp Transfer amount\n */\n function getReserveAccumulatedBetween(uint32 startTimestamp, uint32 endTimestamp)\n external\n returns (uint224);\n\n /**\n * @notice Transfer Reserve token balance to recipient address.\n * @dev Creates checkpoint before token transfer. Increments withdrawAccumulator with amount.\n * @param recipient Account address\n * @param amount Transfer amount\n */\n function withdrawTo(address recipient, uint256 amount) external;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 2000 + }, + "evmVersion": "berlin", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From 35fe2b3ee01a68c71cc40180406b76bd439c1ab1 Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 17:34:32 -0500 Subject: [PATCH 6/7] 1.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32855ed..d4d159c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pooltogether/v4-mainnet", - "version": "1.5.0", + "version": "1.5.1", "main": "index.js", "repository": "git@github.com:pooltogether/v4-mainnet.git", "author": "PoolTogether Inc.", From 26230a67274303b8bf7d8aadac0e5b6babd632e9 Mon Sep 17 00:00:00 2001 From: Pierrick Turelier Date: Fri, 3 Jun 2022 17:35:36 -0500 Subject: [PATCH 7/7] feat(contracts): generate contracts list --- contracts.json | 2 +- history/mainnet.1.5.1.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 history/mainnet.1.5.1.json diff --git a/contracts.json b/contracts.json index ba1fb9f..d761b94 100644 --- a/contracts.json +++ b/contracts.json @@ -1 +1 @@ -{"name":"PoolTogether V4 Mainnet","version":{"major":"1","minor":"5","patch":"0"},"tags":{},"contracts":[{"chainId":1,"address":"0x32e8D4c9d1B711BC958d0Ce8D14b41F77Bb03a64","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x6C04Eeeed2dEFedbC9A0f3f63bf14F39a189F607","type":"BeaconTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x0D33612870cd9A475bBBbB7CC38fC66680dEcAC5","type":"DrawBeacon","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract RNGInterface","name":"_rng","type":"address"},{"internalType":"uint32","name":"_nextDrawId","type":"uint32"},{"internalType":"uint64","name":"_beaconPeriodStart","type":"uint64"},{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"},{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"drawPeriodSeconds","type":"uint32"}],"name":"BeaconPeriodSecondsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"startedAt","type":"uint64"}],"name":"BeaconPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"nextDrawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"DrawBufferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"DrawCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawStarted","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":"contract RNGInterface","name":"rngService","type":"address"}],"name":"RngServiceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"rngTimeout","type":"uint32"}],"name":"RngTimeoutSet","type":"event"},{"inputs":[],"name":"beaconPeriodEndAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beaconPeriodRemainingSeconds","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_time","type":"uint64"}],"name":"calculateNextBeaconPeriodStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateNextBeaconPeriodStartTimeFromCurrentTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canCompleteDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canStartDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBeaconPeriodSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBeaconPeriodStartedAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngLockBlock","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngRequestId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngService","outputs":[{"internalType":"contract RNGInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngTimeout","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isBeaconPeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngRequested","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngTimedOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"}],"name":"setBeaconPeriodSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"setDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract RNGInterface","name":"_rngService","type":"address"}],"name":"setRngService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"name":"setRngTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x78Ea5a9595279DC2F9608283875571b1151F19D4","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x14d0675580C7255043a3AeD3726F5D7f33292730","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdC90a79fcb1DBAd5F05E6C264F84AC4b0d351F94","type":"L1TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionPushed","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xf025a8d9E6080F885e841C8cC0E324368D7C6577","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x35A0dF72E1ea94B52F9EbE0D515928eCb663f39F","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xb9a179DcA5a7bf5f8B9E088437B3A85ebB495eFe","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x2193b28b2BdfBf805506C9D91Ed2021bA6fBc888","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x47a5ABfAcDebf5af312B034B3b748935A0259136","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x24C3e15BdC10Ce2CB1BEc56cd43F397cE9B89430","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x3A06B40C67515cda47E44b57116488F73A441F72","type":"RNGChainlinkV2","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract VRFCoordinatorV2Interface","name":"_vrfCoordinator","type":"address"},{"internalType":"uint64","name":"_subscriptionId","type":"uint64"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"}],"name":"KeyHashSet","type":"event"},{"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":"requestId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RandomNumberCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"subscriptionId","type":"uint64"}],"name":"SubscriptionIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract VRFCoordinatorV2Interface","name":"vrfCoordinator","type":"address"}],"name":"VrfCoordinatorSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRequestId","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRequestFee","outputs":[{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getSubscriptionId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVrfCoordinator","outputs":[{"internalType":"contract VRFCoordinatorV2Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"randomNumber","outputs":[{"internalType":"uint256","name":"randomNum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"name":"setKeyhash","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":"uint64","name":"_subscriptionId","type":"uint64"}],"name":"setSubscriptionId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xadB4D93D84b18b5D82063aCf58b21587c92fdfb5","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x5cFbEE38362B9A60be276763753f64245EA990F7","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdd4d117723C257CEe402285D3aCF218E9A8236E1","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x3Cb049Db6d3E100b8b4765Ca051C809adcC17ed1","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xd89a09084555a7D0ABe7B111b1f78DFEdDd638Be","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xD4F6d570133401079D213EcF4A14FA0B4bfB5b9C","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x44B1d66E7B9d4467139924f31754F34cbC392f44","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x3976BD6F4B82C97314570A77bc1e979f7A839A24","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0C22044B0aA634e26C5B5e50E2B958C7aF59c161","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xc366bF1a054CA495c09B1A722D863ac65746138E","type":"L2TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"DrawAndPrizeDistributionPushed","type":"event"},{"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"},{"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":"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xcf6030BDEaB4E503D186426510aD88C1DA7125A3","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x38004713B1793f00c5B497E3eCC1a50697e5FfaE","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x8141BcFBcEE654c5dE17C4e2B2AF26B67f9B9056","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xA2342489470474536F04cd4DdA2e8658303b305d","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x879e176Ae9Fe9B00c30f4827364eA9e4fB35858D","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0F3137E09349449b62144f0918135dE548FdFeeE","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xCE148f6acFee9FEFb42A736B4976e657f35982b8","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x89Ee77Ce3F4C1b0346FF96E3004ff7C9f972dEF8","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xCa9adB15E33948199066f772C3cb02B62356d764","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x19DE635fb3678D8B8154E37d8C9Cdf182Fe84E60","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x7437db21A0dEB844Fa64223e2d6Db569De9648Ff","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x31bCAF169D25f938A25c2e4C762f3D1D3FA7dB2E","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x0F5F5EF16465371152fC46C72D06fb0ec9392a47","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x01eE1Ea692773f28c45D63133426f21923C3c2Ba","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC660A8De5eB9E123E475Ae9A9f62dB62c92a3648","type":"EIP2612PermitAndDeposit","abi":[{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"_permitSignature","type":"tuple"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"permitAndDepositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC8faa39E06ddB8362cb8E3FFDAdeB5bF7877ECcb","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x87FCF371D68d2429D57Bf1BadcBEEc3463F0DD37","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x83332F908f403ce795D90f677cE3f382FE73f3D1","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x1B20994C3894EcC862e26A9F4EC626A8489DD051","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xA30cB2A488dc616F060a54Ee7971d0bD832547Ec","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC3DAD539E460103c860Bb9Ca547647EDbD4903b6","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x832cB306640dD33542dBa08ca1c13DD6686A3a88","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xf04E5B81e69Cdc3c08BC5Da64ca053AD46a3d029","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xd23723fef8A16B77eaDc1fC822aE4170bA9d4009","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xB27f379C050f6eD0973A01667458af6eCeBc1d90","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x46d2f8e4D8Ff3d76cf252D89dD9b422f04123D2c","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xF830F5Cb2422d555EC34178E27094a816c8F95EC","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}}]} \ No newline at end of file +{"name":"PoolTogether V4 Mainnet","version":{"major":"1","minor":"5","patch":"1"},"tags":{},"contracts":[{"chainId":1,"address":"0x32e8D4c9d1B711BC958d0Ce8D14b41F77Bb03a64","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x6C04Eeeed2dEFedbC9A0f3f63bf14F39a189F607","type":"BeaconTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x0D33612870cd9A475bBBbB7CC38fC66680dEcAC5","type":"DrawBeacon","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract RNGInterface","name":"_rng","type":"address"},{"internalType":"uint32","name":"_nextDrawId","type":"uint32"},{"internalType":"uint64","name":"_beaconPeriodStart","type":"uint64"},{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"},{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"drawPeriodSeconds","type":"uint32"}],"name":"BeaconPeriodSecondsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"startedAt","type":"uint64"}],"name":"BeaconPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"nextDrawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"DrawBufferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"DrawCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawStarted","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":"contract RNGInterface","name":"rngService","type":"address"}],"name":"RngServiceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"rngTimeout","type":"uint32"}],"name":"RngTimeoutSet","type":"event"},{"inputs":[],"name":"beaconPeriodEndAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beaconPeriodRemainingSeconds","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_time","type":"uint64"}],"name":"calculateNextBeaconPeriodStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateNextBeaconPeriodStartTimeFromCurrentTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canCompleteDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canStartDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBeaconPeriodSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBeaconPeriodStartedAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngLockBlock","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngRequestId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngService","outputs":[{"internalType":"contract RNGInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngTimeout","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isBeaconPeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngRequested","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngTimedOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"}],"name":"setBeaconPeriodSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"setDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract RNGInterface","name":"_rngService","type":"address"}],"name":"setRngService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"name":"setRngTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x78Ea5a9595279DC2F9608283875571b1151F19D4","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x14d0675580C7255043a3AeD3726F5D7f33292730","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdC90a79fcb1DBAd5F05E6C264F84AC4b0d351F94","type":"L1TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionPushed","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xf025a8d9E6080F885e841C8cC0E324368D7C6577","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x35A0dF72E1ea94B52F9EbE0D515928eCb663f39F","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xb9a179DcA5a7bf5f8B9E088437B3A85ebB495eFe","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x2193b28b2BdfBf805506C9D91Ed2021bA6fBc888","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x47a5ABfAcDebf5af312B034B3b748935A0259136","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x24C3e15BdC10Ce2CB1BEc56cd43F397cE9B89430","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x3A06B40C67515cda47E44b57116488F73A441F72","type":"RNGChainlinkV2","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract VRFCoordinatorV2Interface","name":"_vrfCoordinator","type":"address"},{"internalType":"uint64","name":"_subscriptionId","type":"uint64"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"}],"name":"KeyHashSet","type":"event"},{"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":"requestId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RandomNumberCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"subscriptionId","type":"uint64"}],"name":"SubscriptionIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract VRFCoordinatorV2Interface","name":"vrfCoordinator","type":"address"}],"name":"VrfCoordinatorSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRequestId","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRequestFee","outputs":[{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getSubscriptionId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVrfCoordinator","outputs":[{"internalType":"contract VRFCoordinatorV2Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"randomNumber","outputs":[{"internalType":"uint256","name":"randomNum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"name":"setKeyhash","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":"uint64","name":"_subscriptionId","type":"uint64"}],"name":"setSubscriptionId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xadB4D93D84b18b5D82063aCf58b21587c92fdfb5","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x5cFbEE38362B9A60be276763753f64245EA990F7","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdd4d117723C257CEe402285D3aCF218E9A8236E1","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xe7934EE0c8b877269A5688ee26dd853785212618","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xd89a09084555a7D0ABe7B111b1f78DFEdDd638Be","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xD4F6d570133401079D213EcF4A14FA0B4bfB5b9C","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x44B1d66E7B9d4467139924f31754F34cbC392f44","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x3976BD6F4B82C97314570A77bc1e979f7A839A24","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0C22044B0aA634e26C5B5e50E2B958C7aF59c161","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xc366bF1a054CA495c09B1A722D863ac65746138E","type":"L2TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"DrawAndPrizeDistributionPushed","type":"event"},{"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"},{"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":"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xcf6030BDEaB4E503D186426510aD88C1DA7125A3","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x38004713B1793f00c5B497E3eCC1a50697e5FfaE","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x8141BcFBcEE654c5dE17C4e2B2AF26B67f9B9056","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xA2342489470474536F04cd4DdA2e8658303b305d","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x879e176Ae9Fe9B00c30f4827364eA9e4fB35858D","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0F3137E09349449b62144f0918135dE548FdFeeE","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xCE148f6acFee9FEFb42A736B4976e657f35982b8","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x89Ee77Ce3F4C1b0346FF96E3004ff7C9f972dEF8","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x1470c87e2db5247A36C60DE3D65D7C972C62EA0f","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x19DE635fb3678D8B8154E37d8C9Cdf182Fe84E60","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x7437db21A0dEB844Fa64223e2d6Db569De9648Ff","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x31bCAF169D25f938A25c2e4C762f3D1D3FA7dB2E","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x0F5F5EF16465371152fC46C72D06fb0ec9392a47","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x01eE1Ea692773f28c45D63133426f21923C3c2Ba","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC660A8De5eB9E123E475Ae9A9f62dB62c92a3648","type":"EIP2612PermitAndDeposit","abi":[{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"_permitSignature","type":"tuple"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"permitAndDepositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC8faa39E06ddB8362cb8E3FFDAdeB5bF7877ECcb","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x87FCF371D68d2429D57Bf1BadcBEEc3463F0DD37","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x83332F908f403ce795D90f677cE3f382FE73f3D1","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x1B20994C3894EcC862e26A9F4EC626A8489DD051","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xA30cB2A488dc616F060a54Ee7971d0bD832547Ec","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC3DAD539E460103c860Bb9Ca547647EDbD4903b6","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x832cB306640dD33542dBa08ca1c13DD6686A3a88","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xf04E5B81e69Cdc3c08BC5Da64ca053AD46a3d029","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xd23723fef8A16B77eaDc1fC822aE4170bA9d4009","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xB27f379C050f6eD0973A01667458af6eCeBc1d90","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x01A1F0699356afeB850f5A80226C35A9319CAf74","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xF830F5Cb2422d555EC34178E27094a816c8F95EC","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}}]} \ No newline at end of file diff --git a/history/mainnet.1.5.1.json b/history/mainnet.1.5.1.json new file mode 100644 index 0000000..d761b94 --- /dev/null +++ b/history/mainnet.1.5.1.json @@ -0,0 +1 @@ +{"name":"PoolTogether V4 Mainnet","version":{"major":"1","minor":"5","patch":"1"},"tags":{},"contracts":[{"chainId":1,"address":"0x32e8D4c9d1B711BC958d0Ce8D14b41F77Bb03a64","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x6C04Eeeed2dEFedbC9A0f3f63bf14F39a189F607","type":"BeaconTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x0D33612870cd9A475bBBbB7CC38fC66680dEcAC5","type":"DrawBeacon","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract RNGInterface","name":"_rng","type":"address"},{"internalType":"uint32","name":"_nextDrawId","type":"uint32"},{"internalType":"uint64","name":"_beaconPeriodStart","type":"uint64"},{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"},{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"drawPeriodSeconds","type":"uint32"}],"name":"BeaconPeriodSecondsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"startedAt","type":"uint64"}],"name":"BeaconPeriodStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"nextDrawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"DrawBufferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"DrawCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rngRequestId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"rngLockBlock","type":"uint32"}],"name":"DrawStarted","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":"contract RNGInterface","name":"rngService","type":"address"}],"name":"RngServiceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"rngTimeout","type":"uint32"}],"name":"RngTimeoutSet","type":"event"},{"inputs":[],"name":"beaconPeriodEndAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beaconPeriodRemainingSeconds","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_time","type":"uint64"}],"name":"calculateNextBeaconPeriodStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateNextBeaconPeriodStartTimeFromCurrentTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canCompleteDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canStartDraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBeaconPeriodSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBeaconPeriodStartedAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngLockBlock","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRngRequestId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngService","outputs":[{"internalType":"contract RNGInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRngTimeout","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isBeaconPeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngRequested","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRngTimedOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_beaconPeriodSeconds","type":"uint32"}],"name":"setBeaconPeriodSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawBuffer","name":"newDrawBuffer","type":"address"}],"name":"setDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract RNGInterface","name":"_rngService","type":"address"}],"name":"setRngService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_rngTimeout","type":"uint32"}],"name":"setRngTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startDraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x78Ea5a9595279DC2F9608283875571b1151F19D4","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x14d0675580C7255043a3AeD3726F5D7f33292730","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdC90a79fcb1DBAd5F05E6C264F84AC4b0d351F94","type":"L1TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionPushed","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xf025a8d9E6080F885e841C8cC0E324368D7C6577","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x35A0dF72E1ea94B52F9EbE0D515928eCb663f39F","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xb9a179DcA5a7bf5f8B9E088437B3A85ebB495eFe","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x2193b28b2BdfBf805506C9D91Ed2021bA6fBc888","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x47a5ABfAcDebf5af312B034B3b748935A0259136","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x24C3e15BdC10Ce2CB1BEc56cd43F397cE9B89430","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x3A06B40C67515cda47E44b57116488F73A441F72","type":"RNGChainlinkV2","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract VRFCoordinatorV2Interface","name":"_vrfCoordinator","type":"address"},{"internalType":"uint64","name":"_subscriptionId","type":"uint64"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"}],"name":"KeyHashSet","type":"event"},{"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":"requestId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RandomNumberCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"subscriptionId","type":"uint64"}],"name":"SubscriptionIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract VRFCoordinatorV2Interface","name":"vrfCoordinator","type":"address"}],"name":"VrfCoordinatorSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRequestId","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRequestFee","outputs":[{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getSubscriptionId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVrfCoordinator","outputs":[{"internalType":"contract VRFCoordinatorV2Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"randomNumber","outputs":[{"internalType":"uint256","name":"randomNum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"name":"setKeyhash","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":"uint64","name":"_subscriptionId","type":"uint64"}],"name":"setSubscriptionId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xadB4D93D84b18b5D82063aCf58b21587c92fdfb5","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0x5cFbEE38362B9A60be276763753f64245EA990F7","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xdd4d117723C257CEe402285D3aCF218E9A8236E1","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xe7934EE0c8b877269A5688ee26dd853785212618","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":1,"address":"0xd89a09084555a7D0ABe7B111b1f78DFEdDd638Be","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xD4F6d570133401079D213EcF4A14FA0B4bfB5b9C","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x44B1d66E7B9d4467139924f31754F34cbC392f44","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x3976BD6F4B82C97314570A77bc1e979f7A839A24","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0C22044B0aA634e26C5B5e50E2B958C7aF59c161","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xc366bF1a054CA495c09B1A722D863ac65746138E","type":"L2TimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"DrawAndPrizeDistributionPushed","type":"event"},{"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"},{"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":"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xcf6030BDEaB4E503D186426510aD88C1DA7125A3","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x38004713B1793f00c5B497E3eCC1a50697e5FfaE","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x8141BcFBcEE654c5dE17C4e2B2AF26B67f9B9056","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xA2342489470474536F04cd4DdA2e8658303b305d","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x879e176Ae9Fe9B00c30f4827364eA9e4fB35858D","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x1DcaD946D10343cc4494D610d6273153FB071772","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x0F3137E09349449b62144f0918135dE548FdFeeE","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0xCE148f6acFee9FEFb42A736B4976e657f35982b8","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x89Ee77Ce3F4C1b0346FF96E3004ff7C9f972dEF8","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x1470c87e2db5247A36C60DE3D65D7C972C62EA0f","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":137,"address":"0x19DE635fb3678D8B8154E37d8C9Cdf182Fe84E60","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x7437db21A0dEB844Fa64223e2d6Db569De9648Ff","type":"ATokenYieldSource","abi":[{"inputs":[{"internalType":"contract ATokenInterface","name":"_aToken","type":"address"},{"internalType":"contract IAaveIncentivesController","name":"_incentivesController","type":"address"},{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"_lendingPoolAddressesProviderRegistry","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAToken","name":"aToken","type":"address"},{"indexed":false,"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"lendingPoolAddressesProviderRegistry","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"ATokenYieldSourceInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"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":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Sponsored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"SuppliedTokenTo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TransferredERC20","type":"event"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract ATokenInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMaxAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"balanceOfToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IAaveIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolAddressesProviderRegistry","outputs":[{"internalType":"contract ILendingPoolAddressesProviderRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"amount","type":"uint256"}],"name":"sponsor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"supplyTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x31bCAF169D25f938A25c2e4C762f3D1D3FA7dB2E","type":"DrawBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"}],"name":"DrawSet","type":"event"},{"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"},{"inputs":[],"name":"MAX_CARDINALITY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getDraws","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDraw","outputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"}],"name":"pushDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_newDraw","type":"tuple"}],"name":"setDraw","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x0F5F5EF16465371152fC46C72D06fb0ec9392a47","type":"DrawCalculator","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionBuffer","name":"_prizeDistributionBuffer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"},{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionBuffer","name":"prizeDistributionBuffer","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract PrizeDistributor","name":"prizeDistributor","type":"address"}],"name":"PrizeDistributorSet","type":"event"},{"inputs":[],"name":"TIERS_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_pickIndicesForDraws","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDrawBuffer","outputs":[{"internalType":"contract IDrawBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getNormalizedBalancesForDrawIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeDistributionBuffer","outputs":[{"internalType":"contract IPrizeDistributionBuffer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x01eE1Ea692773f28c45D63133426f21923C3c2Ba","type":"DrawCalculatorTimelock","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawCalculator","name":"_calculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"drawCalculator","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"LockedDraw","type":"event"},{"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"indexed":false,"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"timelock","type":"tuple"}],"name":"TimelockSet","type":"event"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint32[]","name":"drawIds","type":"uint32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"calculate","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimelock","outputs":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasElapsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"lock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[{"components":[{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"internalType":"struct IDrawCalculatorTimelock.Timelock","name":"_timelock","type":"tuple"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC660A8De5eB9E123E475Ae9A9f62dB62c92a3648","type":"EIP2612PermitAndDeposit","abi":[{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"_permitSignature","type":"tuple"},{"components":[{"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"}],"internalType":"struct DelegateSignature","name":"_delegateSignature","type":"tuple"}],"name":"permitAndDepositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC8faa39E06ddB8362cb8E3FFDAdeB5bF7877ECcb","type":"PrizeDistributionBuffer","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint8","name":"_cardinality","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"cardinality","type":"uint8"}],"name":"Deployed","type":"event"},{"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"},{"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"}],"indexed":false,"internalType":"struct IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"}],"name":"PrizeDistributionSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBufferCardinality","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"prizeDistribution","type":"tuple"},{"internalType":"uint32","name":"drawId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getPrizeDistribution","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 IPrizeDistributionBuffer.PrizeDistribution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeDistributionCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeDistributions","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 IPrizeDistributionBuffer.PrizeDistribution[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"uint32","name":"_drawId","type":"uint32"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"pushPrizeDistribution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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"},{"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 IPrizeDistributionBuffer.PrizeDistribution","name":"_prizeDistribution","type":"tuple"}],"name":"setPrizeDistribution","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x87FCF371D68d2429D57Bf1BadcBEEc3463F0DD37","type":"PrizeDistributionFactory","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"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x83332F908f403ce795D90f677cE3f382FE73f3D1","type":"PrizeDistributor","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","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":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x1B20994C3894EcC862e26A9F4EC626A8489DD051","type":"PrizeFlush","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"contract IReserve","name":"_reserve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":true,"internalType":"contract IReserve","name":"reserve","type":"address"},{"indexed":true,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"DestinationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Flushed","type":"event"},{"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":false,"internalType":"contract IReserve","name":"reserve","type":"address"}],"name":"ReserveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategySet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flush","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"}],"name":"setDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"contract IReserve","name":"_reserve","type":"address"}],"name":"setReserve","outputs":[{"internalType":"contract IReserve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"_strategy","type":"address"}],"name":"setStrategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xA30cB2A488dc616F060a54Ee7971d0bD832547Ec","type":"PrizeSplitStrategy","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPrizePool","name":"_prizePool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract IPrizePool","name":"prizePool","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalPrizeCaptured","type":"uint256"}],"name":"Distributed","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":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"prizeAwarded","type":"uint256"},{"indexed":true,"internalType":"contract IControlledToken","name":"token","type":"address"}],"name":"PrizeSplitAwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PrizeSplitRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint16","name":"percentage","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PrizeSplitSet","type":"event"},{"inputs":[],"name":"ONE_AS_FIXED_POINT_3","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPrizePool","outputs":[{"internalType":"contract IPrizePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prizeSplitIndex","type":"uint256"}],"name":"getPrizeSplit","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeSplits","outputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"","type":"tuple[]"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig","name":"_prizeSplit","type":"tuple"},{"internalType":"uint8","name":"_prizeSplitIndex","type":"uint8"}],"name":"setPrizeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint16","name":"percentage","type":"uint16"}],"internalType":"struct IPrizeSplit.PrizeSplitConfig[]","name":"_newPrizeSplits","type":"tuple[]"}],"name":"setPrizeSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xC3DAD539E460103c860Bb9Ca547647EDbD4903b6","type":"PrizeTierHistory","abi":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"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"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierPushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"indexed":false,"internalType":"struct IPrizeTierHistory.PrizeTier","name":"prizeTier","type":"tuple"}],"name":"PrizeTierSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNewestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestDrawId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"drawId","type":"uint32"}],"name":"getPrizeTier","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getPrizeTierAtIndex","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"}],"name":"getPrizeTierList","outputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"popAndPush","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"nextPrizeTier","type":"tuple"}],"name":"push","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"bitRangeSize","type":"uint8"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint32","name":"maxPicksPerUser","type":"uint32"},{"internalType":"uint32","name":"expiryDuration","type":"uint32"},{"internalType":"uint32","name":"endTimestampOffset","type":"uint32"},{"internalType":"uint256","name":"prize","type":"uint256"},{"internalType":"uint32[16]","name":"tiers","type":"uint32[16]"}],"internalType":"struct IPrizeTierHistory.PrizeTier","name":"newPrizeTier","type":"tuple"}],"name":"replace","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":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x832cB306640dD33542dBa08ca1c13DD6686A3a88","type":"ReceiverTimelockTrigger","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IDrawBuffer","name":"_drawBuffer","type":"address"},{"internalType":"contract IPrizeDistributionFactory","name":"_prizeDistributionFactory","type":"address"},{"internalType":"contract IDrawCalculatorTimelock","name":"_timelock","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawBuffer","name":"drawBuffer","type":"address"},{"indexed":true,"internalType":"contract IPrizeDistributionFactory","name":"prizeDistributionFactory","type":"address"},{"indexed":true,"internalType":"contract IDrawCalculatorTimelock","name":"timelock","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"indexed":false,"internalType":"struct IDrawBeacon.Draw","name":"draw","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalNetworkTicketSupply","type":"uint256"}],"name":"DrawLockedPushedAndTotalNetworkTicketSupplyPushed","type":"event"},{"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"},{"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":"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":"prizeDistributionFactory","outputs":[{"internalType":"contract IPrizeDistributionFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"winningRandomNumber","type":"uint256"},{"internalType":"uint32","name":"drawId","type":"uint32"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint64","name":"beaconPeriodStartedAt","type":"uint64"},{"internalType":"uint32","name":"beaconPeriodSeconds","type":"uint32"}],"internalType":"struct IDrawBeacon.Draw","name":"_draw","type":"tuple"},{"internalType":"uint256","name":"_totalNetworkTicketSupply","type":"uint256"}],"name":"push","outputs":[],"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":[],"name":"timelock","outputs":[{"internalType":"contract IDrawCalculatorTimelock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xf04E5B81e69Cdc3c08BC5Da64ca053AD46a3d029","type":"Reserve","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserveAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawAccumulated","type":"uint256"}],"name":"Checkpoint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"Deployed","type":"event"},{"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":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"uint32","name":"_endTimestamp","type":"uint32"}],"name":"getReserveAccumulatedBetween","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"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":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAccumulator","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xd23723fef8A16B77eaDc1fC822aE4170bA9d4009","type":"TWABDelegator","abi":[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegateeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint96","name":"lockUntil","type":"uint96"},{"indexed":true,"internalType":"address","name":"delegatee","type":"address"},{"indexed":false,"internalType":"contract Delegation","name":"delegation","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"DelegationCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"DelegationFundedFromStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":false,"internalType":"bool","name":"set","type":"bool"}],"name":"RepresentativeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"TransferredDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"slot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"WithdrewDelegationToStake","type":"event"},{"inputs":[],"name":"MAX_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"computeDelegationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"createDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationInstance","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegation","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundDelegationFromStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"}],"name":"getDelegation","outputs":[{"internalType":"contract Delegation","name":"delegation","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"lockUntil","type":"uint256"},{"internalType":"bool","name":"wasCreated","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_representative","type":"address"}],"name":"isRepresentativeOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct PermitAndMulticall.Signature","name":"_permitSignature","type":"tuple"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"permitAndMulticall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_representative","type":"address"},{"internalType":"bool","name":"_set","type":"bool"}],"name":"setRepresentative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferDelegationTo","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"address","name":"_delegatee","type":"address"},{"internalType":"uint96","name":"_lockDuration","type":"uint96"}],"name":"updateDelegatee","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"_slot","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawDelegationToStake","outputs":[{"internalType":"contract Delegation","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xB27f379C050f6eD0973A01667458af6eCeBc1d90","type":"Ticket","abi":[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0x01A1F0699356afeB850f5A80226C35A9319CAf74","type":"TwabRewards","abi":[{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"}],"name":"PromotionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PromotionDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"epochNumber","type":"uint8"}],"name":"PromotionEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"PromotionExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"promotionId","type":"uint256"},{"indexed":false,"internalType":"uint8[]","name":"epochIds","type":"uint8[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"uint256","name":"_tokensPerEpoch","type":"uint256"},{"internalType":"uint48","name":"_epochDuration","type":"uint48"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"createPromotion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"destroyPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"endPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8","name":"_numberOfEpochs","type":"uint8"}],"name":"extendPromotion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getPromotion","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint8","name":"numberOfEpochs","type":"uint8"},{"internalType":"uint48","name":"epochDuration","type":"uint48"},{"internalType":"uint48","name":"createdAt","type":"uint48"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"tokensPerEpoch","type":"uint256"},{"internalType":"uint256","name":"rewardsUnclaimed","type":"uint256"}],"internalType":"struct ITwabRewards.Promotion","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_promotionId","type":"uint256"}],"name":"getRemainingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_promotionId","type":"uint256"},{"internalType":"uint8[]","name":"_epochIds","type":"uint8[]"}],"name":"getRewardsAmount","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}},{"chainId":43114,"address":"0xF830F5Cb2422d555EC34178E27094a816c8F95EC","type":"YieldSourcePrizePool","abi":[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IYieldSource","name":"_yieldSource","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardCaptured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Awarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AwardedExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"AwardedExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"balanceCap","type":"uint256"}],"name":"BalanceCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"}],"name":"ControlledTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"yieldSource","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"ErrorAwardingExternalERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidityCap","type":"uint256"}],"name":"LiquidityCapSet","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":"address","name":"prizeStrategy","type":"address"}],"name":"PrizeStrategySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swept","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract ITicket","name":"ticket","type":"address"}],"name":"TicketSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferredExternalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"contract ITicket","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemed","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"award","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"awardExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"awardExternalERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_externalToken","type":"address"}],"name":"canAwardExternal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"captureAwardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICompLike","name":"_compLike","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"compLikeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"depositToAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBalanceCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizeStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTicket","outputs":[{"internalType":"contract ITicket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_controlledToken","type":"address"}],"name":"isControlled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balanceCap","type":"uint256"}],"name":"setBalanceCap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidityCap","type":"uint256"}],"name":"setLiquidityCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_prizeStrategy","type":"address"}],"name":"setPrizeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITicket","name":"_ticket","type":"address"}],"name":"setTicket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"address","name":"_externalToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferExternalERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldSource","outputs":[{"internalType":"contract IYieldSource","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"tags":[],"extensions":{}}]} \ No newline at end of file