creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev 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 * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\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 is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\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    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "contracts/interfaces/IQuestBoard.sol": {
        "content": "// SPDX-License-Identifier: Unlicensed\npragma solidity 0.8.20;\n\nimport \"./libraries/QuestDataTypes.sol\";\n\ninterface IQuestBoard {\n\n\t/** @notice Struct with all the Quest types */\n    struct QuestTypes {\n        QuestDataTypes.QuestVoteType voteType;\n        QuestDataTypes.QuestRewardsType rewardsType;\n        QuestDataTypes.QuestCloseType closeType;\n    }\n\n\t/** @notice Struct holding the parameters of the Quest common for all periods */\n    struct Quest {\n        // Address of the Quest creator (caller of createQuest() method)\n        address creator;\n        // Address of the ERC20 used for rewards\n        address rewardToken;\n        // Address of the target Gauge\n        address gauge;\n        // Total number of periods for the Quest\n        uint48 duration;\n        // Timestamp where the 1st QuestPeriod starts\n        uint48 periodStart;\n        // Total amount of rewards paid for this Quest\n        // If changes were made to the parameters of this Quest, this will account\n        // any added reward amounts\n        uint256 totalRewardAmount;\n        // Quest Types\n        QuestTypes types;\n    }\n    \n\tfunction getQuestIdsForPeriodForGauge(address gauge, uint256 period) external view returns(uint256[] memory);\n    \n\tfunction nextID() external view returns(uint256);\n\n\tfunction quests(uint256 id) external view returns(Quest memory);\n\n    function updateDistributor(address newDistributor) external;\n    function createFixedQuest(\n        address gauge,\n        address rewardToken,\n        bool startNextPeriod,\n        uint48 duration,\n        uint256 rewardPerVote,\n        uint256 totalRewardAmount,\n        uint256 feeAmount,\n        QuestDataTypes.QuestVoteType voteType,\n        QuestDataTypes.QuestCloseType closeType,\n        address[] calldata voterList\n    ) external returns(uint256);\n    function closeQuestPeriod(uint256 period) external returns(uint256 closed, uint256 skipped);\n    function addMerkleRoot(uint256 questID, uint256 period, uint256 totalAmount, bytes32 merkleRoot) external;\n\n}\n"
      },
      "contracts/interfaces/libraries/QuestDataTypes.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.20;\n\n/** @title Data Types fo Quest Board V2  */\n/// @author Paladin\nlibrary QuestDataTypes {\n\n    // Enums\n\n    /** @notice State of each Period for each Quest */\n    enum PeriodState { ZERO, ACTIVE, CLOSED, DISTRIBUTED }\n    // All Periods are ACTIVE at creation since they voters from past periods are also accounted for the future period\n\n    /** @notice Types of Vote logic for Quests */\n    enum QuestVoteType { NORMAL, BLACKLIST, WHITELIST }\n    // NORMAL: basic vote logic\n    // BLACKLIST: remove the blacklisted voters bias from the gauge biases\n    // WHITELIST: only sum up the whitelisted voters biases\n\n    /** @notice Types of Rewards logic for Quests */\n    enum QuestRewardsType { FIXED, RANGE }\n    // FIXED: reward per vote is fixed\n    // RANGE: reward per vote is a range between min and max, based on the Quest completion between min objective and max objective\n\n    /** @notice Types of logic for undistributed rewards when closing Quest periods */\n    enum QuestCloseType { NORMAL, ROLLOVER, DISTRIBUTE }\n    // NORMAL: undistributed rewards are avaialble to be withdrawn by the creator\n    // ROLLOVER: undistributed rewards are added to the next period, increasing the reward/vote parameter (not allowed for RANGE Quests)\n    // DISTRIBUTE: undistributed rewards are sent to the gauge for direct distribution\n\n}"
      },
      "contracts/libraries/Errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.20;\n\nlibrary Errors {\n    \n    // Commons\n    error AddressZero();\n    error NullAmount();\n    error InvalidParameter();\n    error SameAddress();\n    error ArraySizeMismatch();\n    error AlreadyInitialized();\n\n    // Access Control\n    error CannotBeOwner();\n    error CallerNotPendingOwner();\n    error CallerNotAllowed();\n\n    // Merkle Distributor\n    error EmptyParameters();\n    error InvalidProof();\n    error AlreadyClaimed();\n    error MerkleRootNotUpdated();\n    error EmptyMerkleRoot();\n    error IncorrectQuestID();\n    error QuestAlreadyListed();\n    error QuestNotListed();\n    error PeriodAlreadyUpdated();\n    error PeriodNotClosed();\n    error IncorrectPeriod();\n    error PeriodNotListed();\n    error TokenNotWhitelisted();\n    error IncorrectRewardAmount();\n    error CannotRecoverToken();\n\n    // HolyPalPower\n    error InvalidTimestamp();\n\n    // Vote Controller\n    error AlreadyListed();\n    error LockExpired();\n    error VotingPowerInvalid();\n    error VotingPowerExceeded();\n    error VotingPowerProxyExceeded();\n    error VotingCooldown();\n    error KilledGauge();\n    error NotKilledGauge();\n    error NotAllowedManager();\n    error NotAllowedProxyVoter();\n    error ExpiredProxy();\n    error ProxyAlreadyActive();\n    error ProxyPowerExceeded();\n    error ProxyDurationExceeded();\n    error NotAllowedVoteChange();\n    error MaxVoteListExceeded();\n    error MaxProxyListExceeded();\n    error InvalidGaugeCap();\n\n    // Loot\n    error CreatorAlreadySet();\n    error InvalidId(uint256 id);\n    error VestingNotStarted(uint256 id);\n\n    // Loot Creator\n    error NotListed();\n\n    // Loot Buget\n    error LootBudgetExceedLimit();\n\n    //Maths\n    error ConversionOverflow();\n}"
      },
      "contracts/peripheral/QuestBoardProxy.sol": {
        "content": "//██████╗  █████╗ ██╗      █████╗ ██████╗ ██╗███╗   ██╗\n//██╔══██╗██╔══██╗██║     ██╔══██╗██╔══██╗██║████╗  ██║\n//██████╔╝███████║██║     ███████║██║  ██║██║██╔██╗ ██║\n//██╔═══╝ ██╔══██║██║     ██╔══██║██║  ██║██║██║╚██╗██║\n//██║     ██║  ██║███████╗██║  ██║██████╔╝██║██║ ╚████║\n//╚═╝     ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝╚═╝  ╚═══╝\n \n\n//SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.20;\n\nimport {IQuestBoard} from \"../interfaces/IQuestBoard.sol\";\nimport \"../libraries/Errors.sol\";\nimport \"../utils/Owner.sol\";\n\n/** @title Quest Board Proxy contract */\n/// @author Paladin\n/*\n    Proxy contract for calls from the Loot Creator contract to the Quest Board\n    to handle cases where mutliple active Boards support the same veToken ecosystem\n*/\ncontract QuestBoardProxy is Owner {\n\n    address public mainBoard;\n\n    address[] public otherBoards;\n    mapping(address => bool) public isOtherBoard;\n\n    constructor(address _mainBoard, address[] memory _otherBoards){\n        if(_mainBoard == address(0)) revert Errors.AddressZero();\n        mainBoard = _mainBoard;\n        uint256 length = _otherBoards.length;\n        for(uint256 i; i < length; i++){\n            _addOtherBoard(_otherBoards[i]);\n        }\n    }\n\n    /* \n        This method is only called to receive the length of Quests for the period\n        (to get the number of Quests for that period on a specific gauge)\n        so we can return an empty array of the length reflecting the number of quests \n        on the given gauge for the given period\n    */\n    function getQuestIdsForPeriodForGauge(address gauge, uint256 period) external view returns(uint256[] memory) {\n        uint256 questsCount = IQuestBoard(mainBoard).getQuestIdsForPeriodForGauge(gauge, period).length;\n        uint256 boardLength = otherBoards.length;\n        for(uint256 i; i < boardLength; i++){\n            questsCount += IQuestBoard(otherBoards[i]).getQuestIdsForPeriodForGauge(gauge, period).length;\n        }\n        uint256[] memory questIds = new uint256[](questsCount);\n        return questIds;\n    }\n\n\tfunction quests(uint256 id) external view returns(IQuestBoard.Quest memory) {\n        return IQuestBoard(mainBoard).quests(id);\n    }\n\n    function getAllOtherBoard() external view returns(address[] memory){\n        return otherBoards;\n    }\n\n    function _addOtherBoard(address newBoard) internal {\n        if(newBoard == address(0)) revert Errors.AddressZero();\n        if(isOtherBoard[newBoard] || newBoard == mainBoard) revert Errors.AlreadyListed();\n        otherBoards.push(newBoard);\n        isOtherBoard[newBoard] = true;\n    }\n\n    function addOtherBoard(address newBoard) external onlyOwner {\n        _addOtherBoard(newBoard);\n    }\n\n    function removeOtherBoard(address board) external onlyOwner {\n        if(board == address(0)) revert Errors.AddressZero();\n        if(!isOtherBoard[board] || board == mainBoard) revert Errors.NotListed();\n        isOtherBoard[board] = false;\n        uint256 length = otherBoards.length;\n        for(uint256 i; i < length; i++){\n            if(otherBoards[i] == board){\n                otherBoards[i] = otherBoards[length - 1];\n                otherBoards.pop();\n                break;\n            }\n        }\n    }\n\n}"
      },
      "contracts/utils/Owner.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.20;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"../libraries/Errors.sol\";\n\n/** @title 2-step Ownership  */\n/// @author Paladin\n/*\n    Extends OZ Ownable contract to add 2-step ownership transfer\n*/\n\ncontract Owner is Ownable {\n\n    address public pendingOwner;\n\n    event NewPendingOwner(address indexed previousPendingOwner, address indexed newPendingOwner);\n\n    constructor() Ownable(msg.sender) {}\n\n    function transferOwnership(address newOwner) public override virtual onlyOwner {\n        if(newOwner == address(0)) revert Errors.AddressZero();\n        if(newOwner == owner()) revert Errors.CannotBeOwner();\n        address oldPendingOwner = pendingOwner;\n\n        pendingOwner = newOwner;\n\n        emit NewPendingOwner(oldPendingOwner, newOwner);\n    }\n\n    function acceptOwnership() public virtual {\n        if(msg.sender != pendingOwner) revert Errors.CallerNotPendingOwner();\n        address newOwner = pendingOwner;\n        _transferOwnership(pendingOwner);\n        pendingOwner = address(0);\n\n        emit NewPendingOwner(newOwner, address(0));\n    }\n\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 999999
      },
      "viaIR": true,
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}