{"sources":{"contracts/interfaces/IFidu.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./IERC20withDec.sol\";\n\ninterface IFidu is IERC20withDec {\n  function mintTo(address to, uint256 amount) external;\n\n  function burnFrom(address to, uint256 amount) external;\n\n  function renounceRole(bytes32 role, address account) external;\n}\n"},"contracts/interfaces/IPool.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nabstract contract IPool {\n  uint256 public sharePrice;\n\n  function deposit(uint256 amount) external virtual;\n\n  function withdraw(uint256 usdcAmount) external virtual;\n\n  function withdrawInFidu(uint256 fiduAmount) external virtual;\n\n  function collectInterestAndPrincipal(\n    address from,\n    uint256 interest,\n    uint256 principal\n  ) public virtual;\n\n  function transferFrom(\n    address from,\n    address to,\n    uint256 amount\n  ) public virtual returns (bool);\n\n  function drawdown(address to, uint256 amount) public virtual returns (bool);\n\n  function sweepToCompound() public virtual;\n\n  function sweepFromCompound() public virtual;\n\n  function distributeLosses(address creditlineAddress, int256 writedownDelta) external virtual;\n\n  function assets() public view virtual returns (uint256);\n}\n"},"contracts/protocol/core/Fidu.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-ethereum-package/contracts/presets/ERC20PresetMinterPauser.sol\";\nimport \"./ConfigHelper.sol\";\n\n/**\n * @title Fidu\n * @notice Fidu (symbol: FIDU) is Goldfinch's liquidity token, representing shares\n *  in the Pool. When you deposit, we mint a corresponding amount of Fidu, and when you withdraw, we\n *  burn Fidu. The share price of the Pool implicitly represents the \"exchange rate\" between Fidu\n *  and USDC (or whatever currencies the Pool may allow withdraws in during the future)\n * @author Goldfinch\n */\n\ncontract Fidu is ERC20PresetMinterPauserUpgradeSafe {\n  bytes32 public constant OWNER_ROLE = keccak256(\"OWNER_ROLE\");\n  // $1 threshold to handle potential rounding errors, from differing decimals on Fidu and USDC;\n  uint256 public constant ASSET_LIABILITY_MATCH_THRESHOLD = 1e6;\n  GoldfinchConfig public config;\n  using ConfigHelper for GoldfinchConfig;\n\n  /*\n    We are using our own initializer function so we can set the owner by passing it in.\n    I would override the regular \"initializer\" function, but I can't because it's not marked\n    as \"virtual\" in the parent contract\n  */\n  // solhint-disable-next-line func-name-mixedcase\n  function __initialize__(\n    address owner,\n    string calldata name,\n    string calldata symbol,\n    GoldfinchConfig _config\n  ) external initializer {\n    __Context_init_unchained();\n    __AccessControl_init_unchained();\n    __ERC20_init_unchained(name, symbol);\n\n    __ERC20Burnable_init_unchained();\n    __Pausable_init_unchained();\n    __ERC20Pausable_init_unchained();\n\n    config = _config;\n\n    _setupRole(MINTER_ROLE, owner);\n    _setupRole(PAUSER_ROLE, owner);\n    _setupRole(OWNER_ROLE, owner);\n\n    _setRoleAdmin(MINTER_ROLE, OWNER_ROLE);\n    _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE);\n    _setRoleAdmin(OWNER_ROLE, OWNER_ROLE);\n  }\n\n  /**\n   * @dev Creates `amount` new tokens for `to`.\n   *\n   * See {ERC20-_mint}.\n   *\n   * Requirements:\n   *\n   * - the caller must have the `MINTER_ROLE`.\n   */\n  function mintTo(address to, uint256 amount) public {\n    require(canMint(amount), \"Cannot mint: it would create an asset/liability mismatch\");\n    // This super call restricts to only the minter in its implementation, so we don't need to do it here.\n    super.mint(to, amount);\n  }\n\n  /**\n   * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n   * allowance.\n   *\n   * See {ERC20-_burn} and {ERC20-allowance}.\n   *\n   * Requirements:\n   *\n   * - the caller must have the MINTER_ROLE\n   */\n  function burnFrom(address from, uint256 amount) public override {\n    require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: Must have minter role to burn\");\n    require(canBurn(amount), \"Cannot burn: it would create an asset/liability mismatch\");\n    _burn(from, amount);\n  }\n\n  // Internal functions\n\n  // canMint assumes that the USDC that backs the new shares has already been sent to the Pool\n  function canMint(uint256 newAmount) internal view returns (bool) {\n    ISeniorPool seniorPool = config.getSeniorPool();\n    uint256 liabilities = totalSupply().add(newAmount).mul(seniorPool.sharePrice()).div(fiduMantissa());\n    uint256 liabilitiesInDollars = fiduToUSDC(liabilities);\n    uint256 _assets = seniorPool.assets();\n    if (_assets >= liabilitiesInDollars) {\n      return true;\n    } else {\n      return liabilitiesInDollars.sub(_assets) <= ASSET_LIABILITY_MATCH_THRESHOLD;\n    }\n  }\n\n  // canBurn assumes that the USDC that backed these shares has already been moved out the Pool\n  function canBurn(uint256 amountToBurn) internal view returns (bool) {\n    ISeniorPool seniorPool = config.getSeniorPool();\n    uint256 liabilities = totalSupply().sub(amountToBurn).mul(seniorPool.sharePrice()).div(fiduMantissa());\n    uint256 liabilitiesInDollars = fiduToUSDC(liabilities);\n    uint256 _assets = seniorPool.assets();\n    if (_assets >= liabilitiesInDollars) {\n      return true;\n    } else {\n      return liabilitiesInDollars.sub(_assets) <= ASSET_LIABILITY_MATCH_THRESHOLD;\n    }\n  }\n\n  function fiduToUSDC(uint256 amount) internal pure returns (uint256) {\n    return amount.div(fiduMantissa().div(usdcMantissa()));\n  }\n\n  function fiduMantissa() internal pure returns (uint256) {\n    return uint256(10)**uint256(18);\n  }\n\n  function usdcMantissa() internal pure returns (uint256) {\n    return uint256(10)**uint256(6);\n  }\n\n  function updateGoldfinchConfig() external {\n    require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: Must have minter role to change config\");\n    config = GoldfinchConfig(config.configAddress());\n  }\n}\n"},"contracts/interfaces/ICreditDesk.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nabstract contract ICreditDesk {\n  uint256 public totalWritedowns;\n  uint256 public totalLoansOutstanding;\n\n  function setUnderwriterGovernanceLimit(address underwriterAddress, uint256 limit) external virtual;\n\n  function drawdown(address creditLineAddress, uint256 amount) external virtual;\n\n  function pay(address creditLineAddress, uint256 amount) external virtual;\n\n  function assessCreditLine(address creditLineAddress) external virtual;\n\n  function applyPayment(address creditLineAddress, uint256 amount) external virtual;\n\n  function getNextPaymentAmount(address creditLineAddress, uint256 asOfBLock) external view virtual returns (uint256);\n}\n"},"contracts/interfaces/ICreditLine.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\ninterface ICreditLine {\n  function borrower() external view returns (address);\n\n  function limit() external view returns (uint256);\n\n  function interestApr() external view returns (uint256);\n\n  function paymentPeriodInDays() external view returns (uint256);\n\n  function termInDays() external view returns (uint256);\n\n  function lateFeeApr() external view returns (uint256);\n\n  // Accounting variables\n  function balance() external view returns (uint256);\n\n  function interestOwed() external view returns (uint256);\n\n  function principalOwed() external view returns (uint256);\n\n  function termEndTime() external view returns (uint256);\n\n  function nextDueTime() external view returns (uint256);\n\n  function interestAccruedAsOf() external view returns (uint256);\n\n  function lastFullPaymentTime() external view returns (uint256);\n}\n"},"contracts/interfaces/IPoolTokens.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721.sol\";\n\ninterface IPoolTokens is IERC721 {\n  event TokenMinted(\n    address indexed owner,\n    address indexed pool,\n    uint256 indexed tokenId,\n    uint256 amount,\n    uint256 tranche\n  );\n\n  event TokenRedeemed(\n    address indexed owner,\n    address indexed pool,\n    uint256 indexed tokenId,\n    uint256 principalRedeemed,\n    uint256 interestRedeemed,\n    uint256 tranche\n  );\n  event TokenBurned(address indexed owner, address indexed pool, uint256 indexed tokenId);\n\n  struct TokenInfo {\n    address pool;\n    uint256 tranche;\n    uint256 principalAmount;\n    uint256 principalRedeemed;\n    uint256 interestRedeemed;\n  }\n\n  struct MintParams {\n    uint256 principalAmount;\n    uint256 tranche;\n  }\n\n  function mint(MintParams calldata params, address to) external returns (uint256);\n\n  function redeem(\n    uint256 tokenId,\n    uint256 principalRedeemed,\n    uint256 interestRedeemed\n  ) external;\n\n  function burn(uint256 tokenId) external;\n\n  function onPoolCreated(address newPool) external;\n\n  function getTokenInfo(uint256 tokenId) external view returns (TokenInfo memory);\n\n  function validPool(address sender) external view returns (bool);\n\n  function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool);\n}\n"},"contracts/interfaces/ISeniorPool.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./ITranchedPool.sol\";\n\nabstract contract ISeniorPool {\n  uint256 public sharePrice;\n  uint256 public totalLoansOutstanding;\n  uint256 public totalWritedowns;\n\n  function deposit(uint256 amount) external virtual returns (uint256 depositShares);\n\n  function depositWithPermit(\n    uint256 amount,\n    uint256 deadline,\n    uint8 v,\n    bytes32 r,\n    bytes32 s\n  ) external virtual returns (uint256 depositShares);\n\n  function withdraw(uint256 usdcAmount) external virtual returns (uint256 amount);\n\n  function withdrawInFidu(uint256 fiduAmount) external virtual returns (uint256 amount);\n\n  function sweepToCompound() public virtual;\n\n  function sweepFromCompound() public virtual;\n\n  function invest(ITranchedPool pool) public virtual;\n\n  function estimateInvestment(ITranchedPool pool) public view virtual returns (uint256);\n\n  function investJunior(ITranchedPool pool, uint256 amount) public virtual;\n\n  function redeem(uint256 tokenId) public virtual;\n\n  function writedown(uint256 tokenId) public virtual;\n\n  function calculateWritedown(uint256 tokenId) public view virtual returns (uint256 writedownAmount);\n\n  function assets() public view virtual returns (uint256);\n\n  function getNumShares(uint256 amount) public view virtual returns (uint256);\n}\n"},"contracts/interfaces/IERC20withDec.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol\";\n\n/*\nOnly addition is the `decimals` function, which we need, and which both our Fidu and USDC use, along with most ERC20's.\n*/\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20withDec is IERC20 {\n  /**\n   * @dev Returns the number of decimals used for the token\n   */\n  function decimals() external view returns (uint8);\n}\n"},"contracts/interfaces/ITranchedPool.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./IV2CreditLine.sol\";\n\nabstract contract ITranchedPool {\n  IV2CreditLine public creditLine;\n  uint256 public createdAt;\n\n  enum Tranches {Reserved, Senior, Junior}\n\n  struct TrancheInfo {\n    uint256 id;\n    uint256 principalDeposited;\n    uint256 principalSharePrice;\n    uint256 interestSharePrice;\n    uint256 lockedUntil;\n  }\n\n  function initialize(\n    address _config,\n    address _borrower,\n    uint256 _juniorFeePercent,\n    uint256 _limit,\n    uint256 _interestApr,\n    uint256 _paymentPeriodInDays,\n    uint256 _termInDays,\n    uint256 _lateFeeApr\n  ) public virtual;\n\n  function getTranche(uint256 tranche) external view virtual returns (TrancheInfo memory);\n\n  function pay(uint256 amount) external virtual;\n\n  function lockJuniorCapital() external virtual;\n\n  function lockPool() external virtual;\n\n  function drawdown(uint256 amount) external virtual;\n\n  function deposit(uint256 tranche, uint256 amount) external virtual returns (uint256 tokenId);\n\n  function assess() external virtual;\n\n  function depositWithPermit(\n    uint256 tranche,\n    uint256 amount,\n    uint256 deadline,\n    uint8 v,\n    bytes32 r,\n    bytes32 s\n  ) external virtual returns (uint256 tokenId);\n\n  function availableToWithdraw(uint256 tokenId)\n    external\n    view\n    virtual\n    returns (uint256 interestRedeemable, uint256 principalRedeemable);\n\n  function withdraw(uint256 tokenId, uint256 amount)\n    external\n    virtual\n    returns (uint256 interestWithdrawn, uint256 principalWithdrawn);\n\n  function withdrawMax(uint256 tokenId)\n    external\n    virtual\n    returns (uint256 interestWithdrawn, uint256 principalWithdrawn);\n\n  function withdrawMultiple(uint256[] calldata tokenIds, uint256[] calldata amounts) external virtual;\n}\n"},"contracts/interfaces/IV2CreditLine.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./ICreditLine.sol\";\n\nabstract contract IV2CreditLine is ICreditLine {\n  function principal() external view virtual returns (uint256);\n\n  function totalInterestAccrued() external view virtual returns (uint256);\n\n  function termStartTime() external view virtual returns (uint256);\n\n  function setLimit(uint256 newAmount) external virtual;\n\n  function setBalance(uint256 newBalance) external virtual;\n\n  function setPrincipal(uint256 _principal) external virtual;\n\n  function setTotalInterestAccrued(uint256 _interestAccrued) external virtual;\n\n  function drawdown(uint256 amount) external virtual;\n\n  function assess()\n    external\n    virtual\n    returns (\n      uint256,\n      uint256,\n      uint256\n    );\n\n  function initialize(\n    address _config,\n    address owner,\n    address _borrower,\n    uint256 _limit,\n    uint256 _interestApr,\n    uint256 _paymentPeriodInDays,\n    uint256 _termInDays,\n    uint256 _lateFeeApr\n  ) public virtual;\n\n  function setTermEndTime(uint256 newTermEndTime) external virtual;\n\n  function setNextDueTime(uint256 newNextDueTime) external virtual;\n\n  function setInterestOwed(uint256 newInterestOwed) external virtual;\n\n  function setPrincipalOwed(uint256 newPrincipalOwed) external virtual;\n\n  function setInterestAccruedAsOf(uint256 newInterestAccruedAsOf) external virtual;\n\n  function setWritedownAmount(uint256 newWritedownAmount) external virtual;\n\n  function setLastFullPaymentTime(uint256 newLastFullPaymentTime) external virtual;\n\n  function setLateFeeApr(uint256 newLateFeeApr) external virtual;\n\n  function updateGoldfinchConfig() external virtual;\n}\n"},"contracts/interfaces/ICUSDCContract.sol":{"content":"// SPDX-License-Identifier: MIT\n// Taken from https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./IERC20withDec.sol\";\n\ninterface ICUSDCContract is IERC20withDec {\n  /*** User Interface ***/\n\n  function mint(uint256 mintAmount) external returns (uint256);\n\n  function redeem(uint256 redeemTokens) external returns (uint256);\n\n  function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n  function borrow(uint256 borrowAmount) external returns (uint256);\n\n  function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n  function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n  function liquidateBorrow(\n    address borrower,\n    uint256 repayAmount,\n    address cTokenCollateral\n  ) external returns (uint256);\n\n  function getAccountSnapshot(address account)\n    external\n    view\n    returns (\n      uint256,\n      uint256,\n      uint256,\n      uint256\n    );\n\n  function balanceOfUnderlying(address owner) external returns (uint256);\n\n  function exchangeRateCurrent() external returns (uint256);\n\n  /*** Admin Functions ***/\n\n  function _addReserves(uint256 addAmount) external returns (uint256);\n}\n"},"contracts/protocol/core/ConfigHelper.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./GoldfinchConfig.sol\";\nimport \"../../interfaces/IPool.sol\";\nimport \"../../interfaces/IFidu.sol\";\nimport \"../../interfaces/ISeniorPool.sol\";\nimport \"../../interfaces/ISeniorPoolStrategy.sol\";\nimport \"../../interfaces/ICreditDesk.sol\";\nimport \"../../interfaces/IERC20withDec.sol\";\nimport \"../../interfaces/ICUSDCContract.sol\";\nimport \"../../interfaces/IPoolTokens.sol\";\nimport \"../../interfaces/IGoldfinchFactory.sol\";\n\n/**\n * @title ConfigHelper\n * @notice A convenience library for getting easy access to other contracts and constants within the\n *  protocol, through the use of the GoldfinchConfig contract\n * @author Goldfinch\n */\n\nlibrary ConfigHelper {\n  function getPool(GoldfinchConfig config) internal view returns (IPool) {\n    return IPool(poolAddress(config));\n  }\n\n  function getSeniorPool(GoldfinchConfig config) internal view returns (ISeniorPool) {\n    return ISeniorPool(seniorPoolAddress(config));\n  }\n\n  function getSeniorPoolStrategy(GoldfinchConfig config) internal view returns (ISeniorPoolStrategy) {\n    return ISeniorPoolStrategy(seniorPoolStrategyAddress(config));\n  }\n\n  function getUSDC(GoldfinchConfig config) internal view returns (IERC20withDec) {\n    return IERC20withDec(usdcAddress(config));\n  }\n\n  function getCreditDesk(GoldfinchConfig config) internal view returns (ICreditDesk) {\n    return ICreditDesk(creditDeskAddress(config));\n  }\n\n  function getFidu(GoldfinchConfig config) internal view returns (IFidu) {\n    return IFidu(fiduAddress(config));\n  }\n\n  function getCUSDCContract(GoldfinchConfig config) internal view returns (ICUSDCContract) {\n    return ICUSDCContract(cusdcContractAddress(config));\n  }\n\n  function getPoolTokens(GoldfinchConfig config) internal view returns (IPoolTokens) {\n    return IPoolTokens(poolTokensAddress(config));\n  }\n\n  function getGoldfinchFactory(GoldfinchConfig config) internal view returns (IGoldfinchFactory) {\n    return IGoldfinchFactory(goldfinchFactoryAddress(config));\n  }\n\n  function oneInchAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.OneInch));\n  }\n\n  function creditLineImplementationAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.CreditLineImplementation));\n  }\n\n  function trustedForwarderAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.TrustedForwarder));\n  }\n\n  function configAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchConfig));\n  }\n\n  function poolAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.Pool));\n  }\n\n  function poolTokensAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.PoolTokens));\n  }\n\n  function seniorPoolAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPool));\n  }\n\n  function seniorPoolStrategyAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPoolStrategy));\n  }\n\n  function creditDeskAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.CreditDesk));\n  }\n\n  function goldfinchFactoryAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchFactory));\n  }\n\n  function fiduAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.Fidu));\n  }\n\n  function cusdcContractAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.CUSDCContract));\n  }\n\n  function usdcAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.USDC));\n  }\n\n  function tranchedPoolAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.TranchedPoolImplementation));\n  }\n\n  function migratedTranchedPoolAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.MigratedTranchedPoolImplementation));\n  }\n\n  function reserveAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.TreasuryReserve));\n  }\n\n  function protocolAdminAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.ProtocolAdmin));\n  }\n\n  function borrowerImplementationAddress(GoldfinchConfig config) internal view returns (address) {\n    return config.getAddress(uint256(ConfigOptions.Addresses.BorrowerImplementation));\n  }\n\n  function getReserveDenominator(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.ReserveDenominator));\n  }\n\n  function getWithdrawFeeDenominator(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.WithdrawFeeDenominator));\n  }\n\n  function getLatenessGracePeriodInDays(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.LatenessGracePeriodInDays));\n  }\n\n  function getLatenessMaxDays(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.LatenessMaxDays));\n  }\n\n  function getDrawdownPeriodInSeconds(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.DrawdownPeriodInSeconds));\n  }\n\n  function getTransferRestrictionPeriodInDays(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.TransferRestrictionPeriodInDays));\n  }\n\n  function getLeverageRatio(GoldfinchConfig config) internal view returns (uint256) {\n    return config.getNumber(uint256(ConfigOptions.Numbers.LeverageRatio));\n  }\n}\n"},"contracts/interfaces/IGoldfinchConfig.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\ninterface IGoldfinchConfig {\n  function getNumber(uint256 index) external returns (uint256);\n\n  function getAddress(uint256 index) external returns (address);\n\n  function setAddress(uint256 index, address newAddress) external returns (address);\n\n  function setNumber(uint256 index, uint256 newNumber) external returns (uint256);\n}\n"},"contracts/protocol/core/ConfigOptions.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n/**\n * @title ConfigOptions\n * @notice A central place for enumerating the configurable options of our GoldfinchConfig contract\n * @author Goldfinch\n */\n\nlibrary ConfigOptions {\n  // NEVER EVER CHANGE THE ORDER OF THESE!\n  // You can rename or append. But NEVER change the order.\n  enum Numbers {\n    TransactionLimit,\n    TotalFundsLimit,\n    MaxUnderwriterLimit,\n    ReserveDenominator,\n    WithdrawFeeDenominator,\n    LatenessGracePeriodInDays,\n    LatenessMaxDays,\n    DrawdownPeriodInSeconds,\n    TransferRestrictionPeriodInDays,\n    LeverageRatio\n  }\n  enum Addresses {\n    Pool,\n    CreditLineImplementation,\n    GoldfinchFactory,\n    CreditDesk,\n    Fidu,\n    USDC,\n    TreasuryReserve,\n    ProtocolAdmin,\n    OneInch,\n    TrustedForwarder,\n    CUSDCContract,\n    GoldfinchConfig,\n    PoolTokens,\n    TranchedPoolImplementation,\n    SeniorPool,\n    SeniorPoolStrategy,\n    MigratedTranchedPoolImplementation,\n    BorrowerImplementation\n  }\n\n  function getNumberName(uint256 number) public pure returns (string memory) {\n    Numbers numberName = Numbers(number);\n    if (Numbers.TransactionLimit == numberName) {\n      return \"TransactionLimit\";\n    }\n    if (Numbers.TotalFundsLimit == numberName) {\n      return \"TotalFundsLimit\";\n    }\n    if (Numbers.MaxUnderwriterLimit == numberName) {\n      return \"MaxUnderwriterLimit\";\n    }\n    if (Numbers.ReserveDenominator == numberName) {\n      return \"ReserveDenominator\";\n    }\n    if (Numbers.WithdrawFeeDenominator == numberName) {\n      return \"WithdrawFeeDenominator\";\n    }\n    if (Numbers.LatenessGracePeriodInDays == numberName) {\n      return \"LatenessGracePeriodInDays\";\n    }\n    if (Numbers.LatenessMaxDays == numberName) {\n      return \"LatenessMaxDays\";\n    }\n    if (Numbers.DrawdownPeriodInSeconds == numberName) {\n      return \"DrawdownPeriodInSeconds\";\n    }\n    if (Numbers.TransferRestrictionPeriodInDays == numberName) {\n      return \"TransferRestrictionPeriodInDays\";\n    }\n    if (Numbers.LeverageRatio == numberName) {\n      return \"LeverageRatio\";\n    }\n    revert(\"Unknown value passed to getNumberName\");\n  }\n\n  function getAddressName(uint256 addressKey) public pure returns (string memory) {\n    Addresses addressName = Addresses(addressKey);\n    if (Addresses.Pool == addressName) {\n      return \"Pool\";\n    }\n    if (Addresses.CreditLineImplementation == addressName) {\n      return \"CreditLineImplementation\";\n    }\n    if (Addresses.GoldfinchFactory == addressName) {\n      return \"GoldfinchFactory\";\n    }\n    if (Addresses.CreditDesk == addressName) {\n      return \"CreditDesk\";\n    }\n    if (Addresses.Fidu == addressName) {\n      return \"Fidu\";\n    }\n    if (Addresses.USDC == addressName) {\n      return \"USDC\";\n    }\n    if (Addresses.TreasuryReserve == addressName) {\n      return \"TreasuryReserve\";\n    }\n    if (Addresses.ProtocolAdmin == addressName) {\n      return \"ProtocolAdmin\";\n    }\n    if (Addresses.OneInch == addressName) {\n      return \"OneInch\";\n    }\n    if (Addresses.TrustedForwarder == addressName) {\n      return \"TrustedForwarder\";\n    }\n    if (Addresses.CUSDCContract == addressName) {\n      return \"CUSDCContract\";\n    }\n    if (Addresses.PoolTokens == addressName) {\n      return \"PoolTokens\";\n    }\n    if (Addresses.TranchedPoolImplementation == addressName) {\n      return \"TranchedPoolImplementation\";\n    }\n    if (Addresses.SeniorPool == addressName) {\n      return \"SeniorPool\";\n    }\n    if (Addresses.SeniorPoolStrategy == addressName) {\n      return \"SeniorPoolStrategy\";\n    }\n    if (Addresses.MigratedTranchedPoolImplementation == addressName) {\n      return \"MigratedTranchedPoolImplementation\";\n    }\n    if (Addresses.BorrowerImplementation == addressName) {\n      return \"BorrowerImplementation\";\n    }\n    revert(\"Unknown value passed to getAddressName\");\n  }\n}\n"},"contracts/interfaces/IGoldfinchFactory.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\ninterface IGoldfinchFactory {\n  function createCreditLine() external returns (address);\n\n  function createBorrower(address owner) external returns (address);\n\n  function createPool(\n    address _borrower,\n    uint256 _juniorFeePercent,\n    uint256 _limit,\n    uint256 _interestApr,\n    uint256 _paymentPeriodInDays,\n    uint256 _termInDays,\n    uint256 _lateFeeApr\n  ) external returns (address);\n\n  function createMigratedPool(\n    address _borrower,\n    uint256 _juniorFeePercent,\n    uint256 _limit,\n    uint256 _interestApr,\n    uint256 _paymentPeriodInDays,\n    uint256 _termInDays,\n    uint256 _lateFeeApr\n  ) external returns (address);\n\n  function updateGoldfinchConfig() external;\n}\n"},"contracts/protocol/core/PauserPausable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol\";\nimport \"@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol\";\n\n/**\n * @title PauserPausable\n * @notice Inheriting from OpenZeppelin's Pausable contract, this does small\n *  augmentations to make it work with a PAUSER_ROLE, leveraging the AccessControl contract.\n *  It is meant to be inherited.\n * @author Goldfinch\n */\n\ncontract PauserPausable is AccessControlUpgradeSafe, PausableUpgradeSafe {\n  bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n  // solhint-disable-next-line func-name-mixedcase\n  function __PauserPausable__init() public initializer {\n    __Pausable_init_unchained();\n  }\n\n  /**\n   * @dev Pauses all functions guarded by Pause\n   *\n   * See {Pausable-_pause}.\n   *\n   * Requirements:\n   *\n   * - the caller must have the PAUSER_ROLE.\n   */\n\n  function pause() public onlyPauserRole {\n    _pause();\n  }\n\n  /**\n   * @dev Unpauses the contract\n   *\n   * See {Pausable-_unpause}.\n   *\n   * Requirements:\n   *\n   * - the caller must have the Pauser role\n   */\n  function unpause() public onlyPauserRole {\n    _unpause();\n  }\n\n  modifier onlyPauserRole() {\n    require(hasRole(PAUSER_ROLE, _msgSender()), \"Must have pauser role to perform this action\");\n    _;\n  }\n}\n"},"contracts/protocol/core/GoldfinchConfig.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./BaseUpgradeablePausable.sol\";\nimport \"../../interfaces/IGoldfinchConfig.sol\";\nimport \"./ConfigOptions.sol\";\n\n/**\n * @title GoldfinchConfig\n * @notice This contract stores mappings of useful \"protocol config state\", giving a central place\n *  for all other contracts to access it. For example, the TransactionLimit, or the PoolAddress. These config vars\n *  are enumerated in the `ConfigOptions` library, and can only be changed by admins of the protocol.\n *  Note: While this inherits from BaseUpgradeablePausable, it is not deployed as an upgradeable contract (this\n *    is mostly to save gas costs of having each call go through a proxy)\n * @author Goldfinch\n */\n\ncontract GoldfinchConfig is BaseUpgradeablePausable {\n  bytes32 public constant GO_LISTER_ROLE = keccak256(\"GO_LISTER_ROLE\");\n\n  mapping(uint256 => address) public addresses;\n  mapping(uint256 => uint256) public numbers;\n  mapping(address => bool) public goList;\n\n  event AddressUpdated(address owner, uint256 index, address oldValue, address newValue);\n  event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue);\n\n  event GoListed(address indexed member);\n  event NoListed(address indexed member);\n\n  bool public valuesInitialized;\n\n  function initialize(address owner) public initializer {\n    require(owner != address(0), \"Owner address cannot be empty\");\n\n    __BaseUpgradeablePausable__init(owner);\n\n    _setupRole(GO_LISTER_ROLE, owner);\n\n    _setRoleAdmin(GO_LISTER_ROLE, OWNER_ROLE);\n  }\n\n  function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin {\n    require(addresses[addressIndex] == address(0), \"Address has already been initialized\");\n\n    emit AddressUpdated(msg.sender, addressIndex, addresses[addressIndex], newAddress);\n    addresses[addressIndex] = newAddress;\n  }\n\n  function setNumber(uint256 index, uint256 newNumber) public onlyAdmin {\n    emit NumberUpdated(msg.sender, index, numbers[index], newNumber);\n    numbers[index] = newNumber;\n  }\n\n  function setTreasuryReserve(address newTreasuryReserve) public onlyAdmin {\n    uint256 key = uint256(ConfigOptions.Addresses.TreasuryReserve);\n    emit AddressUpdated(msg.sender, key, addresses[key], newTreasuryReserve);\n    addresses[key] = newTreasuryReserve;\n  }\n\n  function setSeniorPoolStrategy(address newStrategy) public onlyAdmin {\n    uint256 key = uint256(ConfigOptions.Addresses.SeniorPoolStrategy);\n    emit AddressUpdated(msg.sender, key, addresses[key], newStrategy);\n    addresses[key] = newStrategy;\n  }\n\n  function setCreditLineImplementation(address newAddress) public onlyAdmin {\n    uint256 key = uint256(ConfigOptions.Addresses.CreditLineImplementation);\n    emit AddressUpdated(msg.sender, key, addresses[key], newAddress);\n    addresses[key] = newAddress;\n  }\n\n  function setBorrowerImplementation(address newAddress) public onlyAdmin {\n    uint256 key = uint256(ConfigOptions.Addresses.BorrowerImplementation);\n    emit AddressUpdated(msg.sender, key, addresses[key], newAddress);\n    addresses[key] = newAddress;\n  }\n\n  function setGoldfinchConfig(address newAddress) public onlyAdmin {\n    uint256 key = uint256(ConfigOptions.Addresses.GoldfinchConfig);\n    emit AddressUpdated(msg.sender, key, addresses[key], newAddress);\n    addresses[key] = newAddress;\n  }\n\n  function initializeFromOtherConfig(address _initialConfig) public onlyAdmin {\n    require(!valuesInitialized, \"Already initialized values\");\n    IGoldfinchConfig initialConfig = IGoldfinchConfig(_initialConfig);\n    for (uint256 i = 0; i < 10; i++) {\n      setNumber(i, initialConfig.getNumber(i));\n    }\n\n    for (uint256 i = 0; i < 11; i++) {\n      if (getAddress(i) == address(0)) {\n        setAddress(i, initialConfig.getAddress(i));\n      }\n    }\n    valuesInitialized = true;\n  }\n\n  /**\n   * @dev Adds a user to go-list\n   * @param _member address to add to go-list\n   */\n  function addToGoList(address _member) public onlyGoListerRole {\n    goList[_member] = true;\n    emit GoListed(_member);\n  }\n\n  /**\n   * @dev removes a user from go-list\n   * @param _member address to remove from go-list\n   */\n  function removeFromGoList(address _member) public onlyGoListerRole {\n    goList[_member] = false;\n    emit NoListed(_member);\n  }\n\n  /**\n   * @dev adds many users to go-list at once\n   * @param _members addresses to ad to go-list\n   */\n  function bulkAddToGoList(address[] calldata _members) external onlyGoListerRole {\n    for (uint256 i = 0; i < _members.length; i++) {\n      addToGoList(_members[i]);\n    }\n  }\n\n  /**\n   * @dev removes many users from go-list at once\n   * @param _members addresses to remove from go-list\n   */\n  function bulkRemoveFromGoList(address[] calldata _members) external onlyGoListerRole {\n    for (uint256 i = 0; i < _members.length; i++) {\n      removeFromGoList(_members[i]);\n    }\n  }\n\n  /*\n    Using custom getters in case we want to change underlying implementation later,\n    or add checks or validations later on.\n  */\n  function getAddress(uint256 index) public view returns (address) {\n    return addresses[index];\n  }\n\n  function getNumber(uint256 index) public view returns (uint256) {\n    return numbers[index];\n  }\n\n  modifier onlyGoListerRole() {\n    require(hasRole(GO_LISTER_ROLE, _msgSender()), \"Must have go-lister role to perform this action\");\n    _;\n  }\n}\n"},"contracts/interfaces/ISeniorPoolStrategy.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./ISeniorPool.sol\";\nimport \"./ITranchedPool.sol\";\n\nabstract contract ISeniorPoolStrategy {\n  function invest(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256 amount);\n\n  function estimateInvestment(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256);\n}\n"},"contracts/protocol/core/BaseUpgradeablePausable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol\";\nimport \"@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol\";\nimport \"./PauserPausable.sol\";\n\n/**\n * @title BaseUpgradeablePausable contract\n * @notice This is our Base contract that most other contracts inherit from. It includes many standard\n *  useful abilities like ugpradeability, pausability, access control, and re-entrancy guards.\n * @author Goldfinch\n */\n\ncontract BaseUpgradeablePausable is\n  Initializable,\n  AccessControlUpgradeSafe,\n  PauserPausable,\n  ReentrancyGuardUpgradeSafe\n{\n  bytes32 public constant OWNER_ROLE = keccak256(\"OWNER_ROLE\");\n  using SafeMath for uint256;\n  // Pre-reserving a few slots in the base contract in case we need to add things in the future.\n  // This does not actually take up gas cost or storage cost, but it does reserve the storage slots.\n  // See OpenZeppelin's use of this pattern here:\n  // https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/blob/master/contracts/GSN/Context.sol#L37\n  uint256[50] private __gap1;\n  uint256[50] private __gap2;\n  uint256[50] private __gap3;\n  uint256[50] private __gap4;\n\n  // solhint-disable-next-line func-name-mixedcase\n  function __BaseUpgradeablePausable__init(address owner) public initializer {\n    require(owner != address(0), \"Owner cannot be the zero address\");\n    __AccessControl_init_unchained();\n    __Pausable_init_unchained();\n    __ReentrancyGuard_init_unchained();\n\n    _setupRole(OWNER_ROLE, owner);\n    _setupRole(PAUSER_ROLE, owner);\n\n    _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE);\n    _setRoleAdmin(OWNER_ROLE, OWNER_ROLE);\n  }\n\n  function isAdmin() public view returns (bool) {\n    return hasRole(OWNER_ROLE, _msgSender());\n  }\n\n  modifier onlyAdmin() {\n    require(isAdmin(), \"Must have admin role to perform this action\");\n    _;\n  }\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol":{"content":"pragma solidity ^0.6.0;\nimport \"../Initializable.sol\";\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 GSN 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 */\ncontract ContextUpgradeSafe is Initializable {\n    // Empty internal constructor, to prevent people from mistakenly deploying\n    // an instance of this contract, which should be used via inheritance.\n\n    function __Context_init() internal initializer {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal initializer {\n\n\n    }\n\n\n    function _msgSender() internal view virtual returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n\n    uint256[50] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol":{"content":"pragma solidity >=0.4.24 <0.7.0;\n\n\n/**\n * @title Initializable\n *\n * @dev Helper contract to support initializer functions. To use it, replace\n * the constructor with a function that has the `initializer` modifier.\n * WARNING: Unlike constructors, initializer functions must be manually\n * invoked. This applies both to deploying an Initializable contract, as well\n * as extending an Initializable contract via inheritance.\n * WARNING: When used with inheritance, manual care must be taken to not invoke\n * a parent initializer twice, or ensure that all initializers are idempotent,\n * because this is not dealt with automatically as with constructors.\n */\ncontract Initializable {\n\n  /**\n   * @dev Indicates that the contract has been initialized.\n   */\n  bool private initialized;\n\n  /**\n   * @dev Indicates that the contract is in the process of being initialized.\n   */\n  bool private initializing;\n\n  /**\n   * @dev Modifier to use in the initializer function of a contract.\n   */\n  modifier initializer() {\n    require(initializing || isConstructor() || !initialized, \"Contract instance has already been initialized\");\n\n    bool isTopLevelCall = !initializing;\n    if (isTopLevelCall) {\n      initializing = true;\n      initialized = true;\n    }\n\n    _;\n\n    if (isTopLevelCall) {\n      initializing = false;\n    }\n  }\n\n  /// @dev Returns true if and only if the function is running in the constructor\n  function isConstructor() private view returns (bool) {\n    // extcodesize checks the size of the code stored in an address, and\n    // address returns the current address. Since the code is still not\n    // deployed when running a constructor, any checks on its code size will\n    // yield zero, making it an effective way to detect if a contract is\n    // under construction or not.\n    address self = address(this);\n    uint256 cs;\n    assembly { cs := extcodesize(self) }\n    return cs == 0;\n  }\n\n  // Reserved storage space to allow for layout changes in the future.\n  uint256[50] private ______gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol":{"content":"pragma solidity ^0.6.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * 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 */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return sub(a, b, \"SafeMath: subtraction overflow\");\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return div(a, b, \"SafeMath: division by zero\");\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        // Solidity only automatically asserts when dividing by 0\n        require(b > 0, errorMessage);\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return mod(a, b, \"SafeMath: modulo by zero\");\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts with custom message when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b != 0, errorMessage);\n        return a % b;\n    }\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol":{"content":"pragma solidity ^0.6.2;\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        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n        // for accounts without code, i.e. `keccak256('')`\n        bytes32 codehash;\n        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { codehash := extcodehash(account) }\n        return (codehash != accountHash && codehash != 0x0);\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        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{ value: amount }(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"../GSN/Context.sol\";\nimport \"../Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\ncontract PausableUpgradeSafe is Initializable, ContextUpgradeSafe {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n\n    function __Pausable_init() internal initializer {\n        __Context_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal initializer {\n\n\n        _paused = false;\n\n    }\n\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     */\n    modifier whenNotPaused() {\n        require(!_paused, \"Pausable: paused\");\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     */\n    modifier whenPaused() {\n        require(_paused, \"Pausable: not paused\");\n        _;\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    uint256[49] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"../../GSN/Context.sol\";\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../Initializable.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 {ERC20MinterPauser}.\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 guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 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 ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 {\n    using SafeMath for uint256;\n    using Address for address;\n\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    uint8 private _decimals;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n     * a default value of 18.\n     *\n     * To select a different value for {decimals}, use {_setupDecimals}.\n     *\n     * All three of these values are immutable: they can only be set once during\n     * construction.\n     */\n\n    function __ERC20_init(string memory name, string memory symbol) internal initializer {\n        __Context_init_unchained();\n        __ERC20_init_unchained(name, symbol);\n    }\n\n    function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer {\n\n\n        _name = name;\n        _symbol = symbol;\n        _decimals = 18;\n\n    }\n\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view 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 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 {_setupDecimals} is\n     * called.\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 returns (uint8) {\n        return _decimals;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view 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     * - `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(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\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].add(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        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is 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(address sender, address recipient, uint256 amount) 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        _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n        _balances[recipient] = _balances[recipient].add(amount);\n        emit Transfer(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     * - `to` 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 = _totalSupply.add(amount);\n        _balances[account] = _balances[account].add(amount);\n        emit Transfer(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        _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n        _totalSupply = _totalSupply.sub(amount);\n        emit Transfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.\n     *\n     * This is 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(address owner, address spender, uint256 amount) 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 Sets {decimals} to a value other than the default one of 18.\n     *\n     * WARNING: This function should only be called from the constructor. Most\n     * applications that interact with token contracts will not expect\n     * {decimals} to ever change, and may work incorrectly if it does.\n     */\n    function _setupDecimals(uint8 decimals_) internal {\n        _decimals = decimals_;\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 to 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(address from, address to, uint256 amount) internal virtual { }\n\n    uint256[44] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol":{"content":"pragma solidity ^0.6.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(address sender, address recipient, uint256 amount) 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"},"@openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol":{"content":"pragma solidity ^0.6.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`\n * (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping (bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) { // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n            bytes32 lastvalue = set._values[lastIndex];\n\n            // Move the last value to the index where the value to delete is\n            set._values[toDeleteIndex] = lastvalue;\n            // Update the index for the moved value\n            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        require(set._values.length > index, \"EnumerableSet: index out of bounds\");\n        return set._values[index];\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(value)));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(value)));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(value)));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint256(_at(set._inner, index)));\n    }\n\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"../utils/EnumerableSet.sol\";\nimport \"../utils/Address.sol\";\nimport \"../GSN/Context.sol\";\nimport \"../Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n *     require(hasRole(MY_ROLE, _msgSender()));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n */\nabstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe {\n    function __AccessControl_init() internal initializer {\n        __Context_init_unchained();\n        __AccessControl_init_unchained();\n    }\n\n    function __AccessControl_init_unchained() internal initializer {\n\n\n    }\n\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using Address for address;\n\n    struct RoleData {\n        EnumerableSet.AddressSet members;\n        bytes32 adminRole;\n    }\n\n    mapping (bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view returns (bool) {\n        return _roles[role].members.contains(account);\n    }\n\n    /**\n     * @dev Returns the number of accounts that have `role`. Can be used\n     * together with {getRoleMember} to enumerate all bearers of a role.\n     */\n    function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n        return _roles[role].members.length();\n    }\n\n    /**\n     * @dev Returns one of the accounts that have `role`. `index` must be a\n     * value between 0 and {getRoleMemberCount}, non-inclusive.\n     *\n     * Role bearers are not sorted in any particular way, and their ordering may\n     * change at any point.\n     *\n     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n     * you perform all queries on the same block. See the following\n     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n     * for more information.\n     */\n    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n        return _roles[role].members.at(index);\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) public virtual {\n        require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) public virtual {\n        require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) public virtual {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        _roles[role].adminRole = adminRole;\n    }\n\n    function _grantRole(bytes32 role, address account) private {\n        if (_roles[role].members.add(account)) {\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    function _revokeRole(bytes32 role, address account) private {\n        if (_roles[role].members.remove(account)) {\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n\n    uint256[49] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721.sol":{"content":"pragma solidity ^0.6.2;\n\nimport \"../../introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of NFTs in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the NFT specified by `tokenId`.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to\n     * another (`to`).\n     *\n     *\n     *\n     * Requirements:\n     * - `from`, `to` cannot be zero.\n     * - `tokenId` must be owned by `from`.\n     * - If the caller is not `from`, it must be have been allowed to move this\n     * NFT by either {approve} or {setApprovalForAll}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n    /**\n     * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to\n     * another (`to`).\n     *\n     * Requirements:\n     * - If the caller is not `from`, it must be approved to move this NFT by\n     * either {approve} or {setApprovalForAll}.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n    function approve(address to, uint256 tokenId) external;\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    function setApprovalForAll(address operator, bool _approved) external;\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC165.sol":{"content":"pragma solidity ^0.6.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"},"@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol":{"content":"pragma solidity ^0.6.0;\nimport \"../Initializable.sol\";\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 */\ncontract ReentrancyGuardUpgradeSafe is Initializable {\n    bool private _notEntered;\n\n\n    function __ReentrancyGuard_init() internal initializer {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal initializer {\n\n\n        // Storing an initial non-zero value makes deployment a bit more\n        // expensive, but in exchange the refund on every call to nonReentrant\n        // will be lower in amount. Since refunds are capped to a percetange of\n        // the total transaction's gas, it is best to keep them low in cases\n        // like this one, to increase the likelihood of the full refund coming\n        // into effect.\n        _notEntered = true;\n\n    }\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 make 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(_notEntered, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _notEntered = false;\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        _notEntered = true;\n    }\n\n    uint256[49] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"../../GSN/Context.sol\";\nimport \"./ERC20.sol\";\nimport \"../../Initializable.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20BurnableUpgradeSafe is Initializable, ContextUpgradeSafe, ERC20UpgradeSafe {\n    function __ERC20Burnable_init() internal initializer {\n        __Context_init_unchained();\n        __ERC20Burnable_init_unchained();\n    }\n\n    function __ERC20Burnable_init_unchained() internal initializer {\n\n\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from the caller.\n     *\n     * See {ERC20-_burn}.\n     */\n    function burn(uint256 amount) public virtual {\n        _burn(_msgSender(), amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n     * allowance.\n     *\n     * See {ERC20-_burn} and {ERC20-allowance}.\n     *\n     * Requirements:\n     *\n     * - the caller must have allowance for ``accounts``'s tokens of at least\n     * `amount`.\n     */\n    function burnFrom(address account, uint256 amount) public virtual {\n        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \"ERC20: burn amount exceeds allowance\");\n\n        _approve(account, _msgSender(), decreasedAllowance);\n        _burn(account, amount);\n    }\n\n    uint256[50] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Pausable.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"./ERC20.sol\";\nimport \"../../utils/Pausable.sol\";\nimport \"../../Initializable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20PausableUpgradeSafe is Initializable, ERC20UpgradeSafe, PausableUpgradeSafe {\n    function __ERC20Pausable_init() internal initializer {\n        __Context_init_unchained();\n        __Pausable_init_unchained();\n        __ERC20Pausable_init_unchained();\n    }\n\n    function __ERC20Pausable_init_unchained() internal initializer {\n\n\n    }\n\n    /**\n     * @dev See {ERC20-_beforeTokenTransfer}.\n     *\n     * Requirements:\n     *\n     * - the contract must not be paused.\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {\n        super._beforeTokenTransfer(from, to, amount);\n\n        require(!paused(), \"ERC20Pausable: token transfer while paused\");\n    }\n\n    uint256[50] private __gap;\n}\n"},"@openzeppelin/contracts-ethereum-package/contracts/presets/ERC20PresetMinterPauser.sol":{"content":"pragma solidity ^0.6.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../GSN/Context.sol\";\nimport \"../token/ERC20/ERC20.sol\";\nimport \"../token/ERC20/ERC20Burnable.sol\";\nimport \"../token/ERC20/ERC20Pausable.sol\";\nimport \"../Initializable.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n *  - ability for holders to burn (destroy) their tokens\n *  - a minter role that allows for token minting (creation)\n *  - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to aother accounts\n */\ncontract ERC20PresetMinterPauserUpgradeSafe is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, ERC20BurnableUpgradeSafe, ERC20PausableUpgradeSafe {\n    bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n    bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n    /**\n     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n     * account that deploys the contract.\n     *\n     * See {ERC20-constructor}.\n     */\n\n    function initialize(string memory name, string memory symbol) public {\n        __ERC20PresetMinterPauser_init(name, symbol);\n    }\n\n    function __ERC20PresetMinterPauser_init(string memory name, string memory symbol) internal initializer {\n        __Context_init_unchained();\n        __AccessControl_init_unchained();\n        __ERC20_init_unchained(name, symbol);\n        __ERC20Burnable_init_unchained();\n        __Pausable_init_unchained();\n        __ERC20Pausable_init_unchained();\n        __ERC20PresetMinterPauser_init_unchained(name, symbol);\n    }\n\n    function __ERC20PresetMinterPauser_init_unchained(string memory name, string memory symbol) internal initializer {\n\n\n        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n        _setupRole(MINTER_ROLE, _msgSender());\n        _setupRole(PAUSER_ROLE, _msgSender());\n\n    }\n\n\n    /**\n     * @dev Creates `amount` new tokens for `to`.\n     *\n     * See {ERC20-_mint}.\n     *\n     * Requirements:\n     *\n     * - the caller must have the `MINTER_ROLE`.\n     */\n    function mint(address to, uint256 amount) public {\n        require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n        _mint(to, amount);\n    }\n\n    /**\n     * @dev Pauses all token transfers.\n     *\n     * See {ERC20Pausable} and {Pausable-_pause}.\n     *\n     * Requirements:\n     *\n     * - the caller must have the `PAUSER_ROLE`.\n     */\n    function pause() public {\n        require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n        _pause();\n    }\n\n    /**\n     * @dev Unpauses all token transfers.\n     *\n     * See {ERC20Pausable} and {Pausable-_unpause}.\n     *\n     * Requirements:\n     *\n     * - the caller must have the `PAUSER_ROLE`.\n     */\n    function unpause() public {\n        require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n        _unpause();\n    }\n\n    function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20UpgradeSafe, ERC20PausableUpgradeSafe) {\n        super._beforeTokenTransfer(from, to, amount);\n    }\n\n    uint256[50] private __gap;\n}\n"}},"matchId":"2128482","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2024-08-08T14:38:55Z","match":"exact_match","chainId":"1","address":"0xf228BF1F8d11Dc1555fc096a7ab6FCd238f1ED6B"}