{
  "language": "Solidity",
  "sources": {
    "contracts/mock/ERC20Mock.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/ERC20.sol';\n\ncontract ERC20Mock is ERC20 {\n  constructor(\n    string memory name,\n    string memory symbol,\n    address initialAccount,\n    uint256 initialBalance\n  ) ERC20(name, symbol) {\n    _mint(initialAccount, initialBalance);\n  }\n\n  function mint(address account, uint256 amount) public {\n    _mint(account, amount);\n  }\n\n  function burn(address account, uint256 amount) public {\n    _burn(account, amount);\n  }\n\n  function transferInternal(\n    address from,\n    address to,\n    uint256 value\n  ) public {\n    _transfer(from, to, value);\n  }\n\n  function approveInternal(\n    address owner,\n    address spender,\n    uint256 value\n  ) public {\n    _approve(owner, spender, value);\n  }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/ERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin 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 ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(_msgSender(), recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        _approve(_msgSender(), spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * Requirements:\n     *\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``sender``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n\n        uint256 currentAllowance = _allowances[sender][_msgSender()];\n        require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n        unchecked {\n            _approve(sender, _msgSender(), currentAllowance - amount);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        uint256 currentAllowance = _allowances[_msgSender()][spender];\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `sender` to `recipient`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) internal virtual {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(sender, recipient, amount);\n\n        uint256 senderBalance = _balances[sender];\n        require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[sender] = senderBalance - amount;\n        }\n        _balances[recipient] += amount;\n\n        emit Transfer(sender, recipient, amount);\n\n        _afterTokenTransfer(sender, recipient, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n        }\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "contracts/utils/BaseStrategy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/ERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nstruct StrategyParams {\n  uint256 performanceFee;\n  uint256 activation;\n  uint256 debtRatio;\n  uint256 minDebtPerHarvest;\n  uint256 maxDebtPerHarvest;\n  uint256 lastReport;\n  uint256 totalDebt;\n  uint256 totalGain;\n  uint256 totalLoss;\n  bool enforceChangeLimit;\n  uint256 profitLimitRatio;\n  uint256 lossLimitRatio;\n  address customCheck;\n}\n\ninterface VaultAPI is IERC20 {\n  function name() external view returns (string calldata);\n\n  function symbol() external view returns (string calldata);\n\n  function decimals() external view returns (uint256);\n\n  function apiVersion() external pure returns (string memory);\n\n  function permit(\n    address owner,\n    address spender,\n    uint256 amount,\n    uint256 expiry,\n    bytes calldata signature\n  ) external returns (bool);\n\n  // NOTE: Vyper produces multiple signatures for a given function with \"default\" args\n  function deposit() external returns (uint256);\n\n  function deposit(uint256 amount) external returns (uint256);\n\n  function deposit(uint256 amount, address recipient) external returns (uint256);\n\n  // NOTE: Vyper produces multiple signatures for a given function with \"default\" args\n  function withdraw() external returns (uint256);\n\n  function withdraw(uint256 maxShares) external returns (uint256);\n\n  function withdraw(uint256 maxShares, address recipient) external returns (uint256);\n\n  function token() external view returns (address);\n\n  function strategies(address _strategy) external view returns (StrategyParams memory);\n\n  function pricePerShare() external view returns (uint256);\n\n  function totalAssets() external view returns (uint256);\n\n  function depositLimit() external view returns (uint256);\n\n  function maxAvailableShares() external view returns (uint256);\n\n  /**\n   * View how much the Vault would increase this Strategy's borrow limit,\n   * based on its present performance (since its last report). Can be used to\n   * determine expectedReturn in your Strategy.\n   */\n  function creditAvailable() external view returns (uint256);\n\n  /**\n   * View how much the Vault would like to pull back from the Strategy,\n   * based on its present performance (since its last report). Can be used to\n   * determine expectedReturn in your Strategy.\n   */\n  function debtOutstanding() external view returns (uint256);\n\n  /**\n   * View how much the Vault expect this Strategy to return at the current\n   * block, based on its present performance (since its last report). Can be\n   * used to determine expectedReturn in your Strategy.\n   */\n  function expectedReturn() external view returns (uint256);\n\n  /**\n   * This is the main contact point where the Strategy interacts with the\n   * Vault. It is critical that this call is handled as intended by the\n   * Strategy. Therefore, this function will be called by BaseStrategy to\n   * make sure the integration is correct.\n   */\n  function report(\n    uint256 _gain,\n    uint256 _loss,\n    uint256 _debtPayment\n  ) external returns (uint256);\n\n  /**\n   * This function should only be used in the scenario where the Strategy is\n   * being retired but no migration of the positions are possible, or in the\n   * extreme scenario that the Strategy needs to be put into \"Emergency Exit\"\n   * mode in order for it to exit as quickly as possible. The latter scenario\n   * could be for any reason that is considered \"critical\" that the Strategy\n   * exits its position as fast as possible, such as a sudden change in\n   * market conditions leading to losses, or an imminent failure in an\n   * external dependency.\n   */\n  function revokeStrategy() external;\n\n  /**\n   * View the governance address of the Vault to assert privileged functions\n   * can only be called by governance. The Strategy serves the Vault, so it\n   * is subject to governance defined by the Vault.\n   */\n  function governance() external view returns (address);\n\n  /**\n   * View the management address of the Vault to assert privileged functions\n   * can only be called by management. The Strategy serves the Vault, so it\n   * is subject to management defined by the Vault.\n   */\n  function management() external view returns (address);\n\n  /**\n   * View the guardian address of the Vault to assert privileged functions\n   * can only be called by guardian. The Strategy serves the Vault, so it\n   * is subject to guardian defined by the Vault.\n   */\n  function guardian() external view returns (address);\n}\n\n/**\n * This interface is here for the keeper bot to use.\n */\ninterface StrategyAPI {\n  function name() external view returns (string memory);\n\n  function vault() external view returns (address);\n\n  function want() external view returns (address);\n\n  function apiVersion() external pure returns (string memory);\n\n  function keeper() external view returns (address);\n\n  function isActive() external view returns (bool);\n\n  function delegatedAssets() external view returns (uint256);\n\n  function estimatedTotalAssets() external view returns (uint256);\n\n  function tendTrigger(uint256 callCost) external view returns (bool);\n\n  function tend() external;\n\n  function harvestTrigger(uint256 callCost) external view returns (bool);\n\n  function harvest() external;\n\n  event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding);\n}\n\n/**\n * @title Yearn Base Strategy\n * @author yearn.finance\n * @notice\n *  BaseStrategy implements all of the required functionality to interoperate\n *  closely with the Vault contract. This contract should be inherited and the\n *  abstract methods implemented to adapt the Strategy to the particular needs\n *  it has to create a return.\n *\n *  Of special interest is the relationship between `harvest()` and\n *  `vault.report()'. `harvest()` may be called simply because enough time has\n *  elapsed since the last report, and not because any funds need to be moved\n *  or positions adjusted. This is critical so that the Vault may maintain an\n *  accurate picture of the Strategy's performance. See  `vault.report()`,\n *  `harvest()`, and `harvestTrigger()` for further details.\n */\n\nabstract contract BaseStrategy {\n  using SafeERC20 for IERC20;\n  string public metadataURI;\n\n  /**\n   * @notice\n   *  Used to track which version of `StrategyAPI` this Strategy\n   *  implements.\n   * @dev The Strategy's version must match the Vault's `API_VERSION`.\n   * @return A string which holds the current API version of this contract.\n   */\n  function apiVersion() public pure returns (string memory) {\n    return '0.4.2';\n  }\n\n  /**\n   * @notice This Strategy's name.\n   * @dev\n   *  You can use this field to manage the \"version\" of this Strategy, e.g.\n   *  `StrategySomethingOrOtherV1`. However, \"API Version\" is managed by\n   *  `apiVersion()` function above.\n   * @return This Strategy's name.\n   */\n  function name() external view virtual returns (string memory);\n\n  /**\n   * @notice\n   *  The amount (priced in want) of the total assets managed by this strategy should not count\n   *  towards Yearn's TVL calculations.\n   * @dev\n   *  You can override this field to set it to a non-zero value if some of the assets of this\n   *  Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault.\n   *  Note that this value must be strictly less than or equal to the amount provided by\n   *  `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets.\n   *  Also note that this value is used to determine the total assets under management by this\n   *  strategy, for the purposes of computing the management fee in `Vault`\n   * @return\n   *  The amount of assets this strategy manages that should not be included in Yearn's Total Value\n   *  Locked (TVL) calculation across it's ecosystem.\n   */\n  function delegatedAssets() external view virtual returns (uint256) {\n    return 0;\n  }\n\n  VaultAPI public vault;\n  address public strategist;\n  address public rewards;\n  address public keeper;\n\n  IERC20 public want;\n\n  // So indexers can keep track of this\n  event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding);\n\n  event UpdatedStrategist(address newStrategist);\n\n  event UpdatedKeeper(address newKeeper);\n\n  event UpdatedRewards(address rewards);\n\n  event UpdatedMinReportDelay(uint256 delay);\n\n  event UpdatedMaxReportDelay(uint256 delay);\n\n  event UpdatedProfitFactor(uint256 profitFactor);\n\n  event UpdatedDebtThreshold(uint256 debtThreshold);\n\n  event EmergencyExitEnabled();\n\n  event UpdatedMetadataURI(string metadataURI);\n\n  // The minimum number of seconds between harvest calls. See\n  // `setMinReportDelay()` for more details.\n  uint256 public minReportDelay;\n\n  // The maximum number of seconds between harvest calls. See\n  // `setMaxReportDelay()` for more details.\n  uint256 public maxReportDelay;\n\n  // The minimum multiple that `callCost` must be above the credit/profit to\n  // be \"justifiable\". See `setProfitFactor()` for more details.\n  uint256 public profitFactor;\n\n  // Use this to adjust the threshold at which running a debt causes a\n  // harvest trigger. See `setDebtThreshold()` for more details.\n  uint256 public debtThreshold;\n\n  // See note on `setEmergencyExit()`.\n  bool public emergencyExit;\n\n  // modifiers\n  modifier onlyAuthorized() {\n    require(msg.sender == strategist || msg.sender == governance(), '!authorized');\n    _;\n  }\n\n  modifier onlyEmergencyAuthorized() {\n    require(\n      msg.sender == strategist || msg.sender == governance() || msg.sender == vault.guardian() || msg.sender == vault.management(),\n      '!authorized'\n    );\n    _;\n  }\n\n  modifier onlyStrategist() {\n    require(msg.sender == strategist, '!strategist');\n    _;\n  }\n\n  modifier onlyGovernance() {\n    require(msg.sender == governance(), '!authorized');\n    _;\n  }\n\n  modifier onlyKeepers() {\n    require(\n      msg.sender == keeper ||\n        msg.sender == strategist ||\n        msg.sender == governance() ||\n        msg.sender == vault.guardian() ||\n        msg.sender == vault.management(),\n      '!authorized'\n    );\n    _;\n  }\n\n  constructor(address _vault) {\n    _initialize(_vault, msg.sender, msg.sender, msg.sender);\n  }\n\n  /**\n   * @notice\n   *  Initializes the Strategy, this is called only once, when the\n   *  contract is deployed.\n   * @dev `_vault` should implement `VaultAPI`.\n   * @param _vault The address of the Vault responsible for this Strategy.\n   * @param _strategist The address to assign as `strategist`.\n   * The strategist is able to change the reward address\n   * @param _rewards  The address to use for pulling rewards.\n   * @param _keeper The adddress of the _keeper. _keeper\n   * can harvest and tend a strategy.\n   */\n  function _initialize(\n    address _vault,\n    address _strategist,\n    address _rewards,\n    address _keeper\n  ) internal {\n    require(address(want) == address(0), 'Strategy already initialized');\n\n    vault = VaultAPI(_vault);\n    want = IERC20(vault.token());\n    want.safeApprove(_vault, type(uint256).max); // Give Vault unlimited access (might save gas)\n    strategist = _strategist;\n    rewards = _rewards;\n    keeper = _keeper;\n    // initialize variables\n    minReportDelay = 0;\n    maxReportDelay = 86400;\n    profitFactor = 100;\n    debtThreshold = 0;\n\n    vault.approve(rewards, type(uint256).max); // Allow rewards to be pulled\n  }\n\n  /**\n   * @notice\n   *  Used to change `strategist`.\n   *\n   *  This may only be called by governance or the existing strategist.\n   * @param _strategist The new address to assign as `strategist`.\n   */\n  function setStrategist(address _strategist) external onlyAuthorized {\n    require(_strategist != address(0));\n    strategist = _strategist;\n    emit UpdatedStrategist(_strategist);\n  }\n\n  /**\n   * @notice\n   *  Used to change `keeper`.\n   *\n   *  `keeper` is the only address that may call `tend()` or `harvest()`,\n   *  other than `governance()` or `strategist`. However, unlike\n   *  `governance()` or `strategist`, `keeper` may *only* call `tend()`\n   *  and `harvest()`, and no other authorized functions, following the\n   *  principle of least privilege.\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _keeper The new address to assign as `keeper`.\n   */\n  function setKeeper(address _keeper) external onlyAuthorized {\n    require(_keeper != address(0));\n    keeper = _keeper;\n    emit UpdatedKeeper(_keeper);\n  }\n\n  /**\n   * @notice\n   *  Used to change `rewards`. EOA or smart contract which has the permission\n   *  to pull rewards from the vault.\n   *\n   *  This may only be called by the strategist.\n   * @param _rewards The address to use for pulling rewards.\n   */\n  function setRewards(address _rewards) external onlyStrategist {\n    require(_rewards != address(0));\n    vault.approve(rewards, 0);\n    rewards = _rewards;\n    vault.approve(rewards, type(uint256).max);\n    emit UpdatedRewards(_rewards);\n  }\n\n  /**\n   * @notice\n   *  Used to change `minReportDelay`. `minReportDelay` is the minimum number\n   *  of blocks that should pass for `harvest()` to be called.\n   *\n   *  For external keepers (such as the Keep3r network), this is the minimum\n   *  time between jobs to wait. (see `harvestTrigger()`\n   *  for more details.)\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _delay The minimum number of seconds to wait between harvests.\n   */\n  function setMinReportDelay(uint256 _delay) external onlyAuthorized {\n    minReportDelay = _delay;\n    emit UpdatedMinReportDelay(_delay);\n  }\n\n  /**\n   * @notice\n   *  Used to change `maxReportDelay`. `maxReportDelay` is the maximum number\n   *  of blocks that should pass for `harvest()` to be called.\n   *\n   *  For external keepers (such as the Keep3r network), this is the maximum\n   *  time between jobs to wait. (see `harvestTrigger()`\n   *  for more details.)\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _delay The maximum number of seconds to wait between harvests.\n   */\n  function setMaxReportDelay(uint256 _delay) external onlyAuthorized {\n    maxReportDelay = _delay;\n    emit UpdatedMaxReportDelay(_delay);\n  }\n\n  /**\n   * @notice\n   *  Used to change `profitFactor`. `profitFactor` is used to determine\n   *  if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()`\n   *  for more details.)\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _profitFactor A ratio to multiply anticipated\n   * `harvest()` gas cost against.\n   */\n  function setProfitFactor(uint256 _profitFactor) external onlyAuthorized {\n    profitFactor = _profitFactor;\n    emit UpdatedProfitFactor(_profitFactor);\n  }\n\n  /**\n   * @notice\n   *  Sets how far the Strategy can go into loss without a harvest and report\n   *  being required.\n   *\n   *  By default this is 0, meaning any losses would cause a harvest which\n   *  will subsequently report the loss to the Vault for tracking. (See\n   *  `harvestTrigger()` for more details.)\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _debtThreshold How big of a loss this Strategy may carry without\n   * being required to report to the Vault.\n   */\n  function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized {\n    debtThreshold = _debtThreshold;\n    emit UpdatedDebtThreshold(_debtThreshold);\n  }\n\n  /**\n   * @notice\n   *  Used to change `metadataURI`. `metadataURI` is used to store the URI\n   * of the file describing the strategy.\n   *\n   *  This may only be called by governance or the strategist.\n   * @param _metadataURI The URI that describe the strategy.\n   */\n  function setMetadataURI(string calldata _metadataURI) external onlyAuthorized {\n    metadataURI = _metadataURI;\n    emit UpdatedMetadataURI(_metadataURI);\n  }\n\n  /**\n   * Resolve governance address from Vault contract, used to make assertions\n   * on protected functions in the Strategy.\n   */\n  function governance() internal view returns (address) {\n    return vault.governance();\n  }\n\n  /**\n   * @notice\n   *  Provide an accurate conversion from `_amtInWei` (denominated in wei)\n   *  to `want` (using the native decimal characteristics of `want`).\n   * @dev\n   *  Care must be taken when working with decimals to assure that the conversion\n   *  is compatible. As an example:\n   *\n   *      given 1e17 wei (0.1 ETH) as input, and want is USDC (6 decimals),\n   *      with USDC/ETH = 1800, this should give back 1800000000 (180 USDC)\n   *\n   * @param _amtInWei The amount (in wei/1e-18 ETH) to convert to `want`\n   * @return The amount in `want` of `_amtInEth` converted to `want`\n   **/\n  function ethToWant(uint256 _amtInWei) public view virtual returns (uint256);\n\n  /**\n   * @notice\n   *  Provide an accurate estimate for the total amount of assets\n   *  (principle + return) that this Strategy is currently managing,\n   *  denominated in terms of `want` tokens.\n   *\n   *  This total should be \"realizable\" e.g. the total value that could\n   *  *actually* be obtained from this Strategy if it were to divest its\n   *  entire position based on current on-chain conditions.\n   * @dev\n   *  Care must be taken in using this function, since it relies on external\n   *  systems, which could be manipulated by the attacker to give an inflated\n   *  (or reduced) value produced by this function, based on current on-chain\n   *  conditions (e.g. this function is possible to influence through\n   *  flashloan attacks, oracle manipulations, or other DeFi attack\n   *  mechanisms).\n   *\n   *  It is up to governance to use this function to correctly order this\n   *  Strategy relative to its peers in the withdrawal queue to minimize\n   *  losses for the Vault based on sudden withdrawals. This value should be\n   *  higher than the total debt of the Strategy and higher than its expected\n   *  value to be \"safe\".\n   * @return The estimated total assets in this Strategy.\n   */\n  function estimatedTotalAssets() public view virtual returns (uint256);\n\n  /*\n   * @notice\n   *  Provide an indication of whether this strategy is currently \"active\"\n   *  in that it is managing an active position, or will manage a position in\n   *  the future. This should correlate to `harvest()` activity, so that Harvest\n   *  events can be tracked externally by indexing agents.\n   * @return True if the strategy is actively managing a position.\n   */\n  function isActive() public view returns (bool) {\n    return vault.strategies(address(this)).debtRatio > 0 || estimatedTotalAssets() > 0;\n  }\n\n  /**\n   * Perform any Strategy unwinding or other calls necessary to capture the\n   * \"free return\" this Strategy has generated since the last time its core\n   * position(s) were adjusted. Examples include unwrapping extra rewards.\n   * This call is only used during \"normal operation\" of a Strategy, and\n   * should be optimized to minimize losses as much as possible.\n   *\n   * This method returns any realized profits and/or realized losses\n   * incurred, and should return the total amounts of profits/losses/debt\n   * payments (in `want` tokens) for the Vault's accounting (e.g.\n   * `want.balanceOf(this) >= _debtPayment + _profit`).\n   *\n   * `_debtOutstanding` will be 0 if the Strategy is not past the configured\n   * debt limit, otherwise its value will be how far past the debt limit\n   * the Strategy is. The Strategy's debt limit is configured in the Vault.\n   *\n   * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`.\n   *       It is okay for it to be less than `_debtOutstanding`, as that\n   *       should only used as a guide for how much is left to pay back.\n   *       Payments should be made to minimize loss from slippage, debt,\n   *       withdrawal fees, etc.\n   *\n   * See `vault.debtOutstanding()`.\n   */\n  function prepareReturn(uint256 _debtOutstanding)\n    internal\n    virtual\n    returns (\n      uint256 _profit,\n      uint256 _loss,\n      uint256 _debtPayment\n    );\n\n  /**\n   * Perform any adjustments to the core position(s) of this Strategy given\n   * what change the Vault made in the \"investable capital\" available to the\n   * Strategy. Note that all \"free capital\" in the Strategy after the report\n   * was made is available for reinvestment. Also note that this number\n   * could be 0, and you should handle that scenario accordingly.\n   *\n   * See comments regarding `_debtOutstanding` on `prepareReturn()`.\n   */\n  function adjustPosition(uint256 _debtOutstanding) internal virtual;\n\n  /**\n   * Liquidate up to `_amountNeeded` of `want` of this strategy's positions,\n   * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`.\n   * This function should return the amount of `want` tokens made available by the\n   * liquidation. If there is a difference between them, `_loss` indicates whether the\n   * difference is due to a realized loss, or if there is some other sitution at play\n   * (e.g. locked funds) where the amount made available is less than what is needed.\n   *\n   * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained\n   */\n  function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss);\n\n  /**\n   * Liquidate everything and returns the amount that got freed.\n   * This function is used during emergency exit instead of `prepareReturn()` to\n   * liquidate all of the Strategy's positions back to the Vault.\n   */\n\n  function liquidateAllPositions() internal virtual returns (uint256 _amountFreed);\n\n  /**\n   * @notice\n   *  Provide a signal to the keeper that `tend()` should be called. The\n   *  keeper will provide the estimated gas cost that they would pay to call\n   *  `tend()`, and this function should use that estimate to make a\n   *  determination if calling it is \"worth it\" for the keeper. This is not\n   *  the only consideration into issuing this trigger, for example if the\n   *  position would be negatively affected if `tend()` is not called\n   *  shortly, then this can return `true` even if the keeper might be\n   *  \"at a loss\" (keepers are always reimbursed by Yearn).\n   * @dev\n   *  `callCostInWei` must be priced in terms of `wei` (1e-18 ETH).\n   *\n   *  This call and `harvestTrigger()` should never return `true` at the same\n   *  time.\n   * @param callCostInWei The keeper's estimated gas cost to call `tend()` (in wei).\n   * @return `true` if `tend()` should be called, `false` otherwise.\n   */\n  function tendTrigger(uint256 callCostInWei) public view virtual returns (bool) {\n    // We usually don't need tend, but if there are positions that need\n    // active maintainence, overriding this function is how you would\n    // signal for that.\n    // If your implementation uses the cost of the call in want, you can\n    // use uint256 callCost = ethToWant(callCostInWei);\n\n    return false;\n  }\n\n  /**\n   * @notice\n   *  Adjust the Strategy's position. The purpose of tending isn't to\n   *  realize gains, but to maximize yield by reinvesting any returns.\n   *\n   *  See comments on `adjustPosition()`.\n   *\n   *  This may only be called by governance, the strategist, or the keeper.\n   */\n  function tend() external onlyKeepers {\n    // Don't take profits with this call, but adjust for better gains\n    adjustPosition(vault.debtOutstanding());\n  }\n\n  /**\n   * @notice\n   *  Provide a signal to the keeper that `harvest()` should be called. The\n   *  keeper will provide the estimated gas cost that they would pay to call\n   *  `harvest()`, and this function should use that estimate to make a\n   *  determination if calling it is \"worth it\" for the keeper. This is not\n   *  the only consideration into issuing this trigger, for example if the\n   *  position would be negatively affected if `harvest()` is not called\n   *  shortly, then this can return `true` even if the keeper might be \"at a\n   *  loss\" (keepers are always reimbursed by Yearn).\n   * @dev\n   *  `callCostInWei` must be priced in terms of `wei` (1e-18 ETH).\n   *\n   *  This call and `tendTrigger` should never return `true` at the\n   *  same time.\n   *\n   *  See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the\n   *  strategist-controlled parameters that will influence whether this call\n   *  returns `true` or not. These parameters will be used in conjunction\n   *  with the parameters reported to the Vault (see `params`) to determine\n   *  if calling `harvest()` is merited.\n   *\n   *  It is expected that an external system will check `harvestTrigger()`.\n   *  This could be a script run off a desktop or cloud bot (e.g.\n   *  https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py),\n   *  or via an integration with the Keep3r network (e.g.\n   *  https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol).\n   * @param callCostInWei The keeper's estimated gas cost to call `harvest()` (in wei).\n   * @return `true` if `harvest()` should be called, `false` otherwise.\n   */\n  function harvestTrigger(uint256 callCostInWei) public view virtual returns (bool) {\n    uint256 callCost = ethToWant(callCostInWei);\n    StrategyParams memory params = vault.strategies(address(this));\n\n    // Should not trigger if Strategy is not activated\n    if (params.activation == 0) return false;\n\n    // Should not trigger if we haven't waited long enough since previous harvest\n    if ((block.timestamp - params.lastReport) < minReportDelay) return false;\n\n    // Should trigger if hasn't been called in a while\n    if ((block.timestamp - params.lastReport) >= maxReportDelay) return true;\n\n    // If some amount is owed, pay it back\n    // NOTE: Since debt is based on deposits, it makes sense to guard against large\n    //       changes to the value from triggering a harvest directly through user\n    //       behavior. This should ensure reasonable resistance to manipulation\n    //       from user-initiated withdrawals as the outstanding debt fluctuates.\n    uint256 outstanding = vault.debtOutstanding();\n    if (outstanding > debtThreshold) return true;\n\n    // Check for profits and losses\n    uint256 total = estimatedTotalAssets();\n    // Trigger if we have a loss to report\n    if ((total + debtThreshold) < params.totalDebt) return true;\n\n    uint256 profit = 0;\n    if (total > params.totalDebt) profit = total - params.totalDebt; // We've earned a profit!\n\n    // Otherwise, only trigger if it \"makes sense\" economically (gas cost\n    // is <N% of value moved)\n    uint256 credit = vault.creditAvailable();\n    return ((profitFactor * callCost) < (credit + profit));\n  }\n\n  /**\n   * @notice\n   *  Harvests the Strategy, recognizing any profits or losses and adjusting\n   *  the Strategy's position.\n   *\n   *  In the rare case the Strategy is in emergency shutdown, this will exit\n   *  the Strategy's position.\n   *\n   *  This may only be called by governance, the strategist, or the keeper.\n   * @dev\n   *  When `harvest()` is called, the Strategy reports to the Vault (via\n   *  `vault.report()`), so in some cases `harvest()` must be called in order\n   *  to take in profits, to borrow newly available funds from the Vault, or\n   *  otherwise adjust its position. In other cases `harvest()` must be\n   *  called to report to the Vault on the Strategy's position, especially if\n   *  any losses have occurred.\n   */\n  function harvest() external onlyKeepers {\n    uint256 profit = 0;\n    uint256 loss = 0;\n    uint256 debtOutstanding = vault.debtOutstanding();\n    uint256 debtPayment = 0;\n    if (emergencyExit) {\n      // Free up as much capital as possible\n      uint256 amountFreed = liquidateAllPositions();\n      if (amountFreed < debtOutstanding) {\n        loss = debtOutstanding - amountFreed;\n      } else if (amountFreed > debtOutstanding) {\n        profit = amountFreed - debtOutstanding;\n      }\n      debtPayment = debtOutstanding - loss;\n    } else {\n      // Free up returns for Vault to pull\n      (profit, loss, debtPayment) = prepareReturn(debtOutstanding);\n    }\n\n    // Allow Vault to take up to the \"harvested\" balance of this contract,\n    // which is the amount it has earned since the last time it reported to\n    // the Vault.\n    debtOutstanding = vault.report(profit, loss, debtPayment);\n\n    // Check if free returns are left, and re-invest them\n    adjustPosition(debtOutstanding);\n\n    emit Harvested(profit, loss, debtPayment, debtOutstanding);\n  }\n\n  /**\n   * @notice\n   *  Withdraws `_amountNeeded` to `vault`.\n   *\n   *  This may only be called by the Vault.\n   * @param _amountNeeded How much `want` to withdraw.\n   * @return _loss Any realized losses\n   */\n  function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) {\n    require(msg.sender == address(vault), '!vault');\n    // Liquidate as much as possible to `want`, up to `_amountNeeded`\n    uint256 amountFreed;\n    (amountFreed, _loss) = liquidatePosition(_amountNeeded);\n    // Send it directly back (NOTE: Using `msg.sender` saves some gas here)\n    SafeERC20.safeTransfer(want, msg.sender, amountFreed);\n    // NOTE: Reinvest anything leftover on next `tend`/`harvest`\n  }\n\n  /**\n   * Do anything necessary to prepare this Strategy for migration, such as\n   * transferring any reserve or LP tokens, CDPs, or other tokens or stores of\n   * value.\n   */\n  function prepareMigration(address _newStrategy) internal virtual;\n\n  /**\n   * @notice\n   *  Transfers all `want` from this Strategy to `_newStrategy`.\n   *\n   *  This may only be called by the Vault.\n   * @dev\n   * The new Strategy's Vault must be the same as this Strategy's Vault.\n   *  The migration process should be carefully performed to make sure all\n   * the assets are migrated to the new address, which should have never\n   * interacted with the vault before.\n   * @param _newStrategy The Strategy to migrate to.\n   */\n  function migrate(address _newStrategy) external {\n    require(msg.sender == address(vault));\n    require(BaseStrategy(_newStrategy).vault() == vault);\n    prepareMigration(_newStrategy);\n    SafeERC20.safeTransfer(want, _newStrategy, want.balanceOf(address(this)));\n  }\n\n  /**\n   * @notice\n   *  Activates emergency exit. Once activated, the Strategy will exit its\n   *  position upon the next harvest, depositing all funds into the Vault as\n   *  quickly as is reasonable given on-chain conditions.\n   *\n   *  This may only be called by governance or the strategist.\n   * @dev\n   *  See `vault.setEmergencyShutdown()` and `harvest()` for further details.\n   */\n  function setEmergencyExit() external onlyEmergencyAuthorized {\n    emergencyExit = true;\n    vault.revokeStrategy();\n\n    emit EmergencyExitEnabled();\n  }\n\n  /**\n   * Override this to add all tokens/tokenized positions this contract\n   * manages on a *persistent* basis (e.g. not just for swapping back to\n   * want ephemerally).\n   *\n   * NOTE: Do *not* include `want`, already included in `sweep` below.\n   *\n   * Example:\n   * ```\n   *    function protectedTokens() internal override view returns (address[] memory) {\n   *      address[] memory protected = new address[](3);\n   *      protected[0] = tokenA;\n   *      protected[1] = tokenB;\n   *      protected[2] = tokenC;\n   *      return protected;\n   *    }\n   * ```\n   */\n  function protectedTokens() internal view virtual returns (address[] memory);\n\n  /**\n   * @notice\n   *  Removes tokens from this Strategy that are not the type of tokens\n   *  managed by this Strategy. This may be used in case of accidentally\n   *  sending the wrong kind of token to this Strategy.\n   *\n   *  Tokens will be sent to `governance()`.\n   *\n   *  This will fail if an attempt is made to sweep `want`, or any tokens\n   *  that are protected by this Strategy.\n   *\n   *  This may only be called by governance.\n   * @dev\n   *  Implement `protectedTokens()` to specify any additional tokens that\n   *  should be protected from sweeping in addition to `want`.\n   * @param _token The token to transfer out of this vault.\n   */\n  function sweep(address _token) external onlyGovernance {\n    require(_token != address(want), '!want');\n    require(_token != address(vault), '!shares');\n\n    address[] memory _protectedTokens = protectedTokens();\n    for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], '!protected');\n\n    SafeERC20.safeTransfer(IERC20(_token), governance(), IERC20(_token).balanceOf(address(this)));\n  }\n}\n\nabstract contract BaseStrategyInitializable is BaseStrategy {\n  bool public isOriginal = true;\n  event Cloned(address indexed clone);\n\n  constructor(address _vault) BaseStrategy(_vault) {}\n\n  function initialize(\n    address _vault,\n    address _strategist,\n    address _rewards,\n    address _keeper\n  ) external virtual {\n    _initialize(_vault, _strategist, _rewards, _keeper);\n  }\n\n  function clone(address _vault) external returns (address) {\n    require(isOriginal, '!clone');\n    return this.clone(_vault, msg.sender, msg.sender, msg.sender);\n  }\n\n  function clone(\n    address _vault,\n    address _strategist,\n    address _rewards,\n    address _keeper\n  ) external returns (address newStrategy) {\n    // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol\n    bytes20 addressBytes = bytes20(address(this));\n\n    assembly {\n      // EIP-1167 bytecode\n      let clone_code := mload(0x40)\n      mstore(clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n      mstore(add(clone_code, 0x14), addressBytes)\n      mstore(add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n      newStrategy := create(0, clone_code, 0x37)\n    }\n\n    BaseStrategyInitializable(newStrategy).initialize(_vault, _strategist, _rewards, _keeper);\n\n    emit Cloned(newStrategy);\n  }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) private pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/utils/BaseStrategyWithSwapperEnabled.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.4;\n\nimport './BaseStrategy.sol';\nimport './SwapperEnabled.sol';\n\nabstract contract BaseStrategyWithSwapperEnabled is BaseStrategy, SwapperEnabled {\n  constructor(address _vault, address _tradeFactory) BaseStrategy(_vault) SwapperEnabled(_tradeFactory) {}\n\n  // SwapperEnabled onlyGovernance methods\n  function setTradeFactory(address _tradeFactory) external override onlyGovernance {\n    _setTradeFactory(_tradeFactory);\n  }\n\n  function createTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  ) external override onlyGovernance returns (uint256 _id) {\n    return _createTrade(_tokenIn, _tokenOut, _amountIn, _maxSlippage, _deadline);\n  }\n\n  // SwapperEnabled onlyAuthorized methods\n  function cancelPendingTrades(uint256[] calldata _pendingTrades) external override onlyAuthorized {\n    _cancelPendingTrades(_pendingTrades);\n  }\n}\n"
    },
    "contracts/utils/SwapperEnabled.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport '../TradeFactory/TradeFactory.sol';\n\ninterface ISwapperEnabled {\n  event TradeFactorySet(address indexed _tradeFactory);\n  event SwapperSet(string indexed _swapper);\n\n  function tradeFactory() external returns (address _tradeFactory);\n\n  function swapper() external returns (string memory _swapper);\n\n  function setSwapper(string calldata _swapper, bool _migrateSwaps) external;\n\n  function setTradeFactory(address _tradeFactory) external;\n\n  function createTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  ) external returns (uint256 _id);\n\n  function executeTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage\n  ) external returns (uint256 _receivedAmount);\n\n  function executeTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external returns (uint256 _receivedAmount);\n\n  function cancelPendingTrades(uint256[] calldata _pendingTrades) external;\n}\n\n/*\n * SwapperEnabled Abstract\n */\nabstract contract SwapperEnabled is ISwapperEnabled {\n  using SafeERC20 for IERC20;\n\n  address public override tradeFactory;\n\n  constructor(address _tradeFactory) {\n    _setTradeFactory(_tradeFactory);\n  }\n\n  // onlyMultisig:\n  function _setTradeFactory(address _tradeFactory) internal {\n    tradeFactory = _tradeFactory;\n    emit TradeFactorySet(_tradeFactory);\n  }\n\n  // onlyMultisig or internal use:\n  function _createTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  ) internal returns (uint256 _id) {\n    IERC20(_tokenIn).safeIncreaseAllowance(tradeFactory, _amountIn);\n    return ITradeFactoryPositionsHandler(tradeFactory).create(_tokenIn, _tokenOut, _amountIn, _maxSlippage, _deadline);\n  }\n\n  function _executeTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage\n  ) internal returns (uint256 _receivedAmount) {\n    IERC20(_tokenIn).safeIncreaseAllowance(tradeFactory, _amountIn);\n    return ITradeFactoryExecutor(tradeFactory).execute(_tokenIn, _tokenOut, _amountIn, _maxSlippage, '');\n  }\n\n  function _executeTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) internal returns (uint256 _receivedAmount) {\n    IERC20(_tokenIn).safeIncreaseAllowance(tradeFactory, _amountIn);\n    return ITradeFactoryExecutor(tradeFactory).execute(_tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\n  }\n\n  // onlyStrategist or multisig:\n  function _cancelPendingTrades(uint256[] calldata _pendingTrades) internal {\n    for (uint256 i; i < _pendingTrades.length; i++) {\n      _cancelPendingTrade(_pendingTrades[i]);\n    }\n  }\n\n  function _cancelPendingTrade(uint256 _pendingTradeId) internal {\n    (, , , address _tokenIn, , uint256 _amountIn, , ) = ITradeFactoryPositionsHandler(tradeFactory).pendingTradesById(_pendingTradeId);\n    IERC20(_tokenIn).safeDecreaseAllowance(tradeFactory, _amountIn);\n    ITradeFactoryPositionsHandler(tradeFactory).cancelPending(_pendingTradeId);\n  }\n\n  function _tradeFactoryAllowance(address _token) internal view returns (uint256 _allowance) {\n    return IERC20(_token).allowance(address(this), tradeFactory);\n  }\n}\n"
    },
    "contracts/TradeFactory/TradeFactory.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '@lbertenasco/contract-utils/contracts/utils/CollectableDust.sol';\n\nimport './TradeFactoryPositionsHandler.sol';\nimport './TradeFactoryExecutor.sol';\n\ninterface ITradeFactory is ITradeFactoryExecutor, ITradeFactoryPositionsHandler {}\n\ncontract TradeFactory is TradeFactoryExecutor, CollectableDust, ITradeFactory {\n  using SafeERC20 for IERC20;\n  using EnumerableSet for EnumerableSet.UintSet;\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  constructor(\n    address _masterAdmin,\n    address _swapperAdder,\n    address _swapperSetter,\n    address _strategyAdder,\n    address _mechanicsRegistry\n  )\n    TradeFactoryAccessManager(_masterAdmin)\n    TradeFactoryPositionsHandler(_strategyAdder)\n    TradeFactorySwapperHandler(_swapperAdder, _swapperSetter)\n    TradeFactoryExecutor(_mechanicsRegistry)\n  {}\n\n  // Collectable Dust\n  function sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) external virtual override onlyRole(MASTER_ADMIN) {\n    _sendDust(_to, _token, _amount);\n  }\n}\n"
    },
    "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.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.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`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        // 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) {\n            // 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            if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastvalue's index to valueIndex\n            }\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        return set._values[index];\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\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(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, 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(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set 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(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, 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(uint160(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(uint160(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(uint160(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(uint160(uint256(_at(set._inner, index))));\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"
    },
    "@lbertenasco/contract-utils/contracts/utils/CollectableDust.sol": {
      "content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport '../../interfaces/utils/ICollectableDust.sol';\n\nabstract\ncontract CollectableDust is ICollectableDust {\n  using SafeERC20 for IERC20;\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n  EnumerableSet.AddressSet internal protocolTokens;\n\n  constructor() {}\n\n  function _addProtocolToken(address _token) internal {\n    require(!protocolTokens.contains(_token), 'collectable-dust/token-is-part-of-the-protocol');\n    protocolTokens.add(_token);\n  }\n\n  function _removeProtocolToken(address _token) internal {\n    require(protocolTokens.contains(_token), 'collectable-dust/token-not-part-of-the-protocol');\n    protocolTokens.remove(_token);\n  }\n\n  function _sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) internal {\n    require(_to != address(0), 'collectable-dust/cant-send-dust-to-zero-address');\n    require(!protocolTokens.contains(_token), 'collectable-dust/token-is-part-of-the-protocol');\n    if (_token == ETH_ADDRESS) {\n      payable(_to).transfer(_amount);\n    } else {\n      IERC20(_token).safeTransfer(_to, _amount);\n    }\n    emit DustSent(_to, _token, _amount);\n  }\n}\n"
    },
    "contracts/TradeFactory/TradeFactoryPositionsHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\nimport './TradeFactorySwapperHandler.sol';\nimport '../Swapper.sol';\n\ninterface ITradeFactoryPositionsHandler {\n  struct Trade {\n    uint256 _id;\n    address _strategy;\n    address _swapper;\n    address _tokenIn;\n    address _tokenOut;\n    uint256 _amountIn;\n    uint256 _maxSlippage;\n    uint256 _deadline;\n  }\n\n  event TradeCreated(\n    uint256 indexed _id,\n    address _strategy,\n    address _swapper,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  );\n\n  event TradeCanceled(address indexed _strategy, uint256 indexed _id);\n\n  event TradesCanceled(address indexed _strategy, uint256[] _ids);\n\n  event TradesSwapperChanged(address indexed _strategy, uint256[] _ids, address _newSwapper);\n\n  function pendingTradesById(uint256)\n    external\n    view\n    returns (\n      uint256 _id,\n      address _strategy,\n      address _swapper,\n      address _tokenIn,\n      address _tokenOut,\n      uint256 _amountIn,\n      uint256 _maxSlippage,\n      uint256 _deadline\n    );\n\n  function pendingTradesIds() external view returns (uint256[] memory _pendingIds);\n\n  function pendingTradesIds(address _strategy) external view returns (uint256[] memory _pendingIds);\n\n  function create(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  ) external returns (uint256 _id);\n\n  function cancelPending(uint256 _id) external;\n\n  function cancelAllPending() external returns (uint256[] memory _canceledTradesIds);\n\n  function setStrategyAsyncSwapperAsAndChangePending(\n    address _strategy,\n    address _swapper,\n    bool _migrateSwaps\n  ) external returns (uint256[] memory _changedSwapperIds);\n\n  function changeStrategyPendingTradesSwapper(address _strategy, address _swapper) external returns (uint256[] memory _changedSwapperIds);\n}\n\nabstract contract TradeFactoryPositionsHandler is ITradeFactoryPositionsHandler, TradeFactorySwapperHandler {\n  using EnumerableSet for EnumerableSet.UintSet;\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  bytes32 public constant STRATEGY = keccak256('STRATEGY');\n  bytes32 public constant STRATEGY_ADDER = keccak256('STRATEGY_ADDER');\n\n  uint256 private _tradeCounter = 1;\n\n  mapping(uint256 => Trade) public override pendingTradesById;\n\n  EnumerableSet.UintSet internal _pendingTradesIds;\n\n  mapping(address => EnumerableSet.UintSet) internal _pendingTradesByOwner;\n\n  constructor(address _strategyAdder) {\n    _setRoleAdmin(STRATEGY, STRATEGY_ADDER);\n    _setRoleAdmin(STRATEGY_ADDER, MASTER_ADMIN);\n    _setupRole(STRATEGY_ADDER, _strategyAdder);\n  }\n\n  function pendingTradesIds() external view override returns (uint256[] memory _pendingIds) {\n    _pendingIds = new uint256[](_pendingTradesIds.length());\n    for (uint256 i; i < _pendingTradesIds.length(); i++) {\n      _pendingIds[i] = _pendingTradesIds.at(i);\n    }\n  }\n\n  function pendingTradesIds(address _strategy) external view override returns (uint256[] memory _pendingIds) {\n    _pendingIds = new uint256[](_pendingTradesByOwner[_strategy].length());\n    for (uint256 i; i < _pendingTradesByOwner[_strategy].length(); i++) {\n      _pendingIds[i] = _pendingTradesByOwner[_strategy].at(i);\n    }\n  }\n\n  function create(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _deadline\n  ) external override onlyRole(STRATEGY) returns (uint256 _id) {\n    require(strategyAsyncSwapper[msg.sender] != address(0), 'TF: no strategy swapper');\n    require(_tokenIn != address(0) && _tokenOut != address(0), 'TradeFactory: zero address');\n    require(_amountIn > 0, 'TradeFactory: zero amount');\n    require(_maxSlippage > 0, 'TradeFactory: zero slippage');\n    require(block.timestamp < _deadline, 'TradeFactory: deadline too soon');\n    _id = _tradeCounter;\n    Trade memory _trade = Trade(\n      _tradeCounter,\n      msg.sender,\n      strategyAsyncSwapper[msg.sender],\n      _tokenIn,\n      _tokenOut,\n      _amountIn,\n      _maxSlippage,\n      _deadline\n    );\n    pendingTradesById[_trade._id] = _trade;\n    _pendingTradesByOwner[msg.sender].add(_trade._id);\n    _pendingTradesIds.add(_trade._id);\n    _tradeCounter += 1;\n    emit TradeCreated(\n      _trade._id,\n      _trade._strategy,\n      _trade._swapper,\n      _trade._tokenIn,\n      _trade._tokenOut,\n      _trade._amountIn,\n      _trade._maxSlippage,\n      _trade._deadline\n    );\n  }\n\n  function cancelPending(uint256 _id) external override onlyRole(STRATEGY) {\n    require(_pendingTradesIds.contains(_id), 'TradeFactory: trade not pending');\n    require(pendingTradesById[_id]._strategy == msg.sender, 'TradeFactory: does not own trade');\n    Trade memory _trade = pendingTradesById[_id];\n    _removePendingTrade(_trade._strategy, _id);\n    emit TradeCanceled(msg.sender, _id);\n  }\n\n  function cancelAllPending() external override onlyRole(STRATEGY) returns (uint256[] memory _canceledTradesIds) {\n    require(_pendingTradesByOwner[msg.sender].length() > 0, 'TradeFactory: no trades pending from strategy');\n    _canceledTradesIds = new uint256[](_pendingTradesByOwner[msg.sender].length());\n    for (uint256 i; i < _pendingTradesByOwner[msg.sender].length(); i++) {\n      _canceledTradesIds[i] = _pendingTradesByOwner[msg.sender].at(i);\n    }\n    for (uint256 i; i < _canceledTradesIds.length; i++) {\n      _removePendingTrade(msg.sender, _canceledTradesIds[i]);\n    }\n    emit TradesCanceled(msg.sender, _canceledTradesIds);\n  }\n\n  function setStrategyAsyncSwapperAsAndChangePending(\n    address _strategy,\n    address _swapper,\n    bool _migrateSwaps\n  ) external override onlyRole(SWAPPER_SETTER) returns (uint256[] memory _changedSwapperIds) {\n    this.setStrategyAsyncSwapper(_strategy, _swapper);\n    if (_migrateSwaps) {\n      return _changeStrategyPendingTradesSwapper(_strategy, _swapper);\n    }\n  }\n\n  function changeStrategyPendingTradesSwapper(address _strategy, address _swapper)\n    external\n    override\n    onlyRole(SWAPPER_SETTER)\n    returns (uint256[] memory _changedSwapperIds)\n  {\n    require(_swappers.contains(_swapper), 'TradeFactory: invalid swapper');\n    return _changeStrategyPendingTradesSwapper(_strategy, _swapper);\n  }\n\n  function _changeStrategyPendingTradesSwapper(address _strategy, address _swapper) internal returns (uint256[] memory _changedSwapperIds) {\n    _changedSwapperIds = new uint256[](_pendingTradesByOwner[_strategy].length());\n    for (uint256 i; i < _pendingTradesByOwner[_strategy].length(); i++) {\n      pendingTradesById[_pendingTradesByOwner[_strategy].at(i)]._swapper = _swapper;\n      _changedSwapperIds[i] = _pendingTradesByOwner[_strategy].at(i);\n    }\n    emit TradesSwapperChanged(_strategy, _changedSwapperIds, _swapper);\n  }\n\n  function _removePendingTrade(address _strategy, uint256 _id) internal {\n    _pendingTradesByOwner[_strategy].remove(_id);\n    _pendingTradesIds.remove(_id);\n    delete pendingTradesById[_id];\n  }\n}\n"
    },
    "contracts/TradeFactory/TradeFactoryExecutor.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '@lbertenasco/contract-utils/contracts/utils/Machinery.sol';\n\nimport './TradeFactoryPositionsHandler.sol';\n\ninterface ITradeFactoryExecutor {\n  event SyncTradeExecuted(\n    address indexed _strategy,\n    address indexed _swapper,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes _data,\n    uint256 _receivedAmount\n  );\n\n  event AsyncTradeExecuted(uint256 indexed _id, uint256 _receivedAmount);\n\n  event AsyncTradeExpired(uint256 indexed _id);\n\n  event SwapperAndTokenEnabled(address indexed _swapper, address _token);\n\n  function approvedTokensBySwappers(address _swapper) external view returns (address[] memory _tokens);\n\n  function execute(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external returns (uint256 _receivedAmount);\n\n  function execute(uint256 _id, bytes calldata _data) external returns (uint256 _receivedAmount);\n\n  function expire(uint256 _id) external returns (uint256 _freedAmount);\n}\n\nabstract contract TradeFactoryExecutor is ITradeFactoryExecutor, TradeFactoryPositionsHandler, Machinery {\n  using SafeERC20 for IERC20;\n  using EnumerableSet for EnumerableSet.UintSet;\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  constructor(address _mechanicsRegistry) Machinery(_mechanicsRegistry) {}\n\n  mapping(address => EnumerableSet.AddressSet) internal _approvedTokensBySwappers;\n\n  function approvedTokensBySwappers(address _swapper) external view override returns (address[] memory _tokens) {\n    _tokens = new address[](_approvedTokensBySwappers[_swapper].length());\n    for (uint256 i = 0; i < _approvedTokensBySwappers[_swapper].length(); i++) {\n      _tokens[i] = _approvedTokensBySwappers[_swapper].at(i);\n    }\n  }\n\n  // Machinery\n  function setMechanicsRegistry(address _mechanicsRegistry) external virtual override onlyRole(MASTER_ADMIN) {\n    _setMechanicsRegistry(_mechanicsRegistry);\n  }\n\n  function execute(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external override onlyRole(STRATEGY) returns (uint256 _receivedAmount) {\n    address _swapper = strategySyncSwapper[msg.sender];\n    require(_swappers.contains(_swapper), 'TradeFactory: invalid swapper');\n    require(_tokenIn != address(0) && _tokenOut != address(0), 'TradeFactory: zero address');\n    require(_amountIn > 0, 'TradeFactory: zero amount');\n    require(_maxSlippage > 0, 'TradeFactory: zero slippage');\n    if (!_approvedTokensBySwappers[_swapper].contains(_tokenIn)) {\n      _enableSwapperToken(_swapper, _tokenIn);\n    }\n    IERC20(_tokenIn).safeTransferFrom(msg.sender, address(this), _amountIn);\n    _receivedAmount = ISwapper(_swapper).swap(msg.sender, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\n    emit SyncTradeExecuted(msg.sender, _swapper, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data, _receivedAmount);\n  }\n\n  // TradeFactoryExecutor\n  function execute(uint256 _id, bytes calldata _data) external override onlyMechanic returns (uint256 _receivedAmount) {\n    require(_pendingTradesIds.contains(_id), 'TradeFactory: trade not pending');\n    Trade memory _trade = pendingTradesById[_id];\n    require(block.timestamp <= _trade._deadline, 'TradeFactory: trade has expired');\n    require(_swappers.contains(_trade._swapper), 'TradeFactory: invalid swapper');\n    if (!_approvedTokensBySwappers[_trade._swapper].contains(_trade._tokenIn)) {\n      _enableSwapperToken(_trade._swapper, _trade._tokenIn);\n    }\n    IERC20(_trade._tokenIn).safeTransferFrom(_trade._strategy, address(this), _trade._amountIn);\n\n    _receivedAmount = ISwapper(_trade._swapper).swap(\n      _trade._strategy,\n      _trade._tokenIn,\n      _trade._tokenOut,\n      _trade._amountIn,\n      _trade._maxSlippage,\n      _data\n    );\n\n    _removePendingTrade(_trade._strategy, _id);\n    emit AsyncTradeExecuted(_id, _receivedAmount);\n  }\n\n  function expire(uint256 _id) external override onlyMechanic returns (uint256 _freedAmount) {\n    require(_pendingTradesIds.contains(_id), 'TradeFactory: trade not pending');\n    Trade memory _trade = pendingTradesById[_id];\n    require(_trade._deadline <= block.timestamp, 'TradeFactory: trade not expired');\n    _freedAmount = _trade._amountIn;\n    // We have to take tokens from strategy, to decrease the allowance\n    IERC20(_trade._tokenIn).safeTransferFrom(_trade._strategy, address(this), _trade._amountIn);\n    // Send tokens back to strategy\n    IERC20(_trade._tokenIn).safeTransfer(_trade._strategy, _trade._amountIn);\n    // Remove trade\n    _removePendingTrade(_trade._strategy, _id);\n    emit AsyncTradeExpired(_id);\n  }\n\n  function _enableSwapperToken(address _swapper, address _token) internal {\n    IERC20(_token).safeApprove(_swapper, type(uint256).max);\n    _approvedTokensBySwappers[_swapper].add(_token);\n    emit SwapperAndTokenEnabled(_swapper, _token);\n  }\n}\n"
    },
    "@lbertenasco/contract-utils/interfaces/utils/ICollectableDust.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\ninterface ICollectableDust {\n  event DustSent(address _to, address token, uint256 amount);\n\n  function sendDust(address _to, address _token, uint256 _amount) external;\n}\n"
    },
    "contracts/TradeFactory/TradeFactorySwapperHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/access/AccessControl.sol';\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '../Swapper.sol';\nimport './TradeFactoryAccessManager.sol';\n\ninterface ITradeFactorySwapperHandler {\n  event SyncStrategySwapperSet(address indexed _strategy, address _swapper);\n  event AsyncStrategySwapperSet(address indexed _strategy, address _swapper);\n  event SwapperAdded(address _swapper);\n  event SwapperRemoved(address _swapper);\n\n  function strategySyncSwapper(address _strategy) external view returns (address _swapper);\n\n  function strategyAsyncSwapper(address _strategy) external view returns (address _swapper);\n\n  function swappers() external view returns (address[] memory _swappersList);\n\n  function isSwapper(address _swapper) external view returns (bool);\n\n  function swapperStrategies(address _swapper) external view returns (address[] memory _strategies);\n\n  function setStrategySyncSwapper(address _strategy, address _swapper) external;\n\n  function setStrategyAsyncSwapper(address _strategy, address _swapper) external;\n\n  function addSwapper(address _swapper) external;\n\n  function addSwappers(address[] memory __swappers) external;\n\n  function removeSwapper(address _swapper) external;\n\n  function removeSwappers(address[] memory __swappers) external;\n}\n\nabstract contract TradeFactorySwapperHandler is ITradeFactorySwapperHandler, TradeFactoryAccessManager {\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  bytes32 public constant SWAPPER_ADDER = keccak256('SWAPPER_ADDER');\n  bytes32 public constant SWAPPER_SETTER = keccak256('SWAPPER_SETTER');\n\n  // swappers list\n  EnumerableSet.AddressSet internal _swappers;\n  // swapper -> strategy list (useful to know if we can safely deprecate a swapper)\n  mapping(address => EnumerableSet.AddressSet) internal _swapperStrategies;\n  // strategy -> async swapper\n  mapping(address => address) public override strategyAsyncSwapper;\n  // strategy -> sync swapper\n  mapping(address => address) public override strategySyncSwapper;\n\n  constructor(address _swapperAdder, address _swapperSetter) {\n    _setRoleAdmin(SWAPPER_ADDER, MASTER_ADMIN);\n    _setRoleAdmin(SWAPPER_SETTER, MASTER_ADMIN);\n    _setupRole(SWAPPER_ADDER, _swapperAdder);\n    _setupRole(SWAPPER_SETTER, _swapperSetter);\n  }\n\n  function isSwapper(address _swapper) external view override returns (bool) {\n    return _swappers.contains(_swapper);\n  }\n\n  function swappers() external view override returns (address[] memory _swappersList) {\n    _swappersList = new address[](_swappers.length());\n    for (uint256 i = 0; i < _swappers.length(); i++) {\n      _swappersList[i] = _swappers.at(i);\n    }\n  }\n\n  function swapperStrategies(address _swapper) external view override returns (address[] memory _strategies) {\n    _strategies = new address[](_swapperStrategies[_swapper].length());\n    for (uint256 i = 0; i < _swapperStrategies[_swapper].length(); i++) {\n      _strategies[i] = _swapperStrategies[_swapper].at(i);\n    }\n  }\n\n  function setStrategySyncSwapper(address _strategy, address _swapper) external override onlyRole(SWAPPER_SETTER) {\n    // we check that swapper being added is async\n    require(ISwapper(_swapper).SWAPPER_TYPE() == ISwapper.SwapperType.SYNC, 'TF: not sync swapper');\n    // we check that swapper is not already added\n    require(_swappers.contains(_swapper), 'TradeFactory: invalid swapper');\n    // remove strategy from previous swapper if any\n    if (strategySyncSwapper[_strategy] != address(0)) _swapperStrategies[strategySyncSwapper[_strategy]].remove(_strategy);\n    // set new strategy's sync swapper\n    strategySyncSwapper[_strategy] = _swapper;\n    // add strategy into new swapper\n    _swapperStrategies[_swapper].add(_strategy);\n    emit SyncStrategySwapperSet(_strategy, _swapper);\n  }\n\n  function setStrategyAsyncSwapper(address _strategy, address _swapper) external override onlyRole(SWAPPER_SETTER) {\n    // we check that swapper being added is async\n    require(ISwapper(_swapper).SWAPPER_TYPE() == ISwapper.SwapperType.ASYNC, 'TF: not async swapper');\n    // we check that swapper is not already added\n    require(_swappers.contains(_swapper), 'TradeFactory: invalid swapper');\n    // remove strategy from previous swapper if any\n    if (strategyAsyncSwapper[_strategy] != address(0)) _swapperStrategies[strategyAsyncSwapper[_strategy]].remove(_strategy);\n    // set new strategy's async swapper\n    strategyAsyncSwapper[_strategy] = _swapper;\n    // add strategy into new swapper\n    _swapperStrategies[_swapper].add(_strategy);\n    emit AsyncStrategySwapperSet(_strategy, _swapper);\n  }\n\n  function _addSwapper(address _swapper) internal {\n    require(_swapper != address(0), 'TF: zero address');\n    require(_swappers.add(_swapper), 'TF: swapper already added');\n    emit SwapperAdded(_swapper);\n  }\n\n  function addSwapper(address _swapper) external override onlyRole(SWAPPER_ADDER) {\n    _addSwapper(_swapper);\n  }\n\n  function addSwappers(address[] memory __swappers) external override onlyRole(SWAPPER_ADDER) {\n    for (uint256 i = 0; i < __swappers.length; i++) {\n      _addSwapper(__swappers[i]);\n    }\n  }\n\n  function _removeSwapper(address _swapper) internal {\n    require(_swappers.remove(_swapper), 'TF: swapper not added');\n    // TODO: SHOULD NOT BE ABLE TO REMOVE SWAPPER IF SWAPPER IS ASSIGNED TO STRAT\n    emit SwapperRemoved(_swapper);\n  }\n\n  function removeSwapper(address _swapper) external override onlyRole(SWAPPER_ADDER) {\n    _removeSwapper(_swapper);\n  }\n\n  function removeSwappers(address[] memory __swappers) external override onlyRole(SWAPPER_ADDER) {\n    for (uint256 i = 0; i < __swappers.length; i++) {\n      _removeSwapper(__swappers[i]);\n    }\n  }\n}\n"
    },
    "contracts/Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport '@lbertenasco/contract-utils/contracts/utils/Governable.sol';\nimport '@lbertenasco/contract-utils/contracts/utils/CollectableDust.sol';\n\ninterface ISwapper {\n  enum SwapperType {\n    ASYNC,\n    SYNC\n  }\n\n  event Swapped(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    uint256 _receivedAmount,\n    bytes _data\n  );\n\n  // solhint-disable-next-line func-name-mixedcase\n  function SLIPPAGE_PRECISION() external view returns (uint256);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function TRADE_FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function SWAPPER_TYPE() external view returns (SwapperType);\n\n  function swap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external returns (uint256 _receivedAmount);\n}\n\nabstract contract Swapper is ISwapper, Governable, CollectableDust {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  uint256 public immutable override SLIPPAGE_PRECISION = 10000; // 1 is 0.0001%, 1_000 is 0.1%\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override TRADE_FACTORY;\n\n  constructor(address _governor, address _tradeFactory) Governable(_governor) {\n    require(_tradeFactory != address(0), 'Swapper: zero address');\n    TRADE_FACTORY = _tradeFactory;\n  }\n\n  modifier onlyTradeFactory() {\n    require(msg.sender == TRADE_FACTORY, 'Swapper: not trade factory');\n    _;\n  }\n\n  function _assertPreSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage\n  ) internal pure {\n    require(_receiver != address(0), 'Swapper: zero address');\n    require(_tokenIn != address(0) && _tokenOut != address(0), 'Swapper: zero address');\n    require(_amountIn > 0, 'Swapper: zero amount');\n    require(_maxSlippage > 0, 'Swapper: zero slippage');\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) internal virtual returns (uint256 _receivedAmount);\n\n  function swap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external virtual override onlyTradeFactory returns (uint256 _receivedAmount) {\n    _assertPreSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage);\n    IERC20(_tokenIn).safeTransferFrom(TRADE_FACTORY, address(this), _amountIn);\n    _receivedAmount = _executeSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\n    emit Swapped(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _receivedAmount, _data);\n  }\n\n  function sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) external virtual override onlyGovernor {\n    _sendDust(_to, _token, _amount);\n  }\n}\n"
    },
    "@openzeppelin/contracts/access/AccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    function grantRole(bytes32 role, address account) external;\n\n    function revokeRole(bytes32 role, address account) external;\n\n    function renounceRole(bytes32 role, address account) external;\n}\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\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, msg.sender));\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 *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n    struct RoleData {\n        mapping(address => bool) 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 `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\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 Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role, _msgSender());\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        Strings.toHexString(uint160(account), 20),\n                        \" is missing role \",\n                        Strings.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\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 override 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 override onlyRole(getRoleAdmin(role)) {\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 override onlyRole(getRoleAdmin(role)) {\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 override {\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     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);\n        _roles[role].adminRole = adminRole;\n    }\n\n    function _grantRole(bytes32 role, address account) private {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    function _revokeRole(bytes32 role, address account) private {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n}\n"
    },
    "contracts/TradeFactory/TradeFactoryAccessManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/access/AccessControl.sol';\n\nabstract contract TradeFactoryAccessManager is AccessControl {\n  bytes32 public constant MASTER_ADMIN = keccak256('MASTER_ADMIN');\n\n  constructor(address _masterAdmin) {\n    _setRoleAdmin(MASTER_ADMIN, MASTER_ADMIN);\n    _setupRole(MASTER_ADMIN, _masterAdmin);\n  }\n}\n"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    },
    "@lbertenasco/contract-utils/contracts/utils/Governable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.4;\n\nimport '../../interfaces/utils/IGovernable.sol';\n\ncontract Governable is IGovernable {\n  address public override governor;\n  address public override pendingGovernor;\n\n  constructor(address _governor) {\n    require(_governor != address(0), 'governable/governor-should-not-be-zero-address');\n    governor = _governor;\n  }\n\n  function setPendingGovernor(address _pendingGovernor) external virtual override onlyGovernor {\n    _setPendingGovernor(_pendingGovernor);\n  }\n\n  function acceptGovernor() external virtual override onlyPendingGovernor {\n    _acceptGovernor();\n  }\n\n  function _setPendingGovernor(address _pendingGovernor) internal {\n    require(_pendingGovernor != address(0), 'governable/pending-governor-should-not-be-zero-addres');\n    pendingGovernor = _pendingGovernor;\n    emit PendingGovernorSet(_pendingGovernor);\n  }\n\n  function _acceptGovernor() internal {\n    governor = pendingGovernor;\n    pendingGovernor = address(0);\n    emit GovernorAccepted();\n  }\n\n  function isGovernor(address _account) public view override returns (bool _isGovernor) {\n    return _account == governor;\n  }\n\n  modifier onlyGovernor {\n    require(isGovernor(msg.sender), 'governable/only-governor');\n    _;\n  }\n\n  modifier onlyPendingGovernor {\n    require(msg.sender == pendingGovernor, 'governable/only-pending-governor');\n    _;\n  }\n}\n"
    },
    "@lbertenasco/contract-utils/interfaces/utils/IGovernable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\ninterface IGovernable {\n  event PendingGovernorSet(address pendingGovernor);\n  event GovernorAccepted();\n\n  function setPendingGovernor(address _pendingGovernor) external;\n  function acceptGovernor() external;\n\n  function governor() external view returns (address _governor);\n  function pendingGovernor() external view returns (address _pendingGovernor);\n\n  function isGovernor(address _account) external view returns (bool _isGovernor);\n}\n"
    },
    "@lbertenasco/contract-utils/contracts/utils/Machinery.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.4;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport '../../interfaces/utils/IMachinery.sol';\nimport '../../interfaces/mechanics/IMechanicsRegistry.sol';\n\ncontract Machinery is IMachinery {\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  IMechanicsRegistry internal _mechanicsRegistry;\n\n  constructor(address __mechanicsRegistry) {\n    _setMechanicsRegistry(__mechanicsRegistry);\n  }\n\n  modifier onlyMechanic {\n    require(_mechanicsRegistry.isMechanic(msg.sender), 'Machinery: not mechanic');\n    _;\n  }\n\n  function setMechanicsRegistry(address __mechanicsRegistry) external virtual override {\n    _setMechanicsRegistry(__mechanicsRegistry);\n  }\n\n  function _setMechanicsRegistry(address __mechanicsRegistry) internal {\n    _mechanicsRegistry = IMechanicsRegistry(__mechanicsRegistry);\n  }\n\n  // View helpers\n  function mechanicsRegistry() external view override returns (address _mechanicRegistry) {\n    return address(_mechanicsRegistry);\n  }\n\n  function isMechanic(address _mechanic) public view override returns (bool _isMechanic) {\n    return _mechanicsRegistry.isMechanic(_mechanic);\n  }\n\n}\n"
    },
    "@lbertenasco/contract-utils/interfaces/utils/IMachinery.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\ninterface IMachinery {\n    // View helpers\n    function mechanicsRegistry() external view returns (address _mechanicsRegistry);\n    function isMechanic(address mechanic) external view returns (bool _isMechanic);\n\n    // Setters\n    function setMechanicsRegistry(address _mechanicsRegistry) external;\n\n}\n"
    },
    "@lbertenasco/contract-utils/interfaces/mechanics/IMechanicsRegistry.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\ninterface IMechanicsRegistry {\n    event MechanicAdded(address _mechanic);\n    event MechanicRemoved(address _mechanic);\n\n    function addMechanic(address _mechanic) external;\n\n    function removeMechanic(address _mechanic) external;\n\n    function mechanics() external view returns (address[] memory _mechanicsList);\n\n    function isMechanic(address mechanic) external view returns (bool _isMechanic);\n\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactoryPositionsHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../TradeFactory/TradeFactoryPositionsHandler.sol';\nimport './TradeFactorySwapperHandler.sol';\n\ncontract TradeFactoryPositionsHandlerMock is TradeFactorySwapperHandlerMock, TradeFactoryPositionsHandler {\n  constructor(\n    address _masterAdmin, \n    address _swapperAdder, \n    address _swapperSetter, \n    address _strategyAdder\n  ) TradeFactoryPositionsHandler(_strategyAdder) TradeFactorySwapperHandlerMock(_masterAdmin, _swapperAdder, _swapperSetter) {}\n\n  function removePendingTrade(address _strategy, uint256 _id) external {\n    _removePendingTrade(_strategy, _id);\n  }\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactorySwapperHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '../../TradeFactory/TradeFactorySwapperHandler.sol';\n\ncontract TradeFactorySwapperHandlerMock is TradeFactorySwapperHandler {\n  using EnumerableSet for EnumerableSet.AddressSet;\n  \n  constructor(address _masterAdmin, address _swapperAdder, address _swapperSetter) TradeFactorySwapperHandler(_swapperAdder, _swapperSetter) TradeFactoryAccessManager(_masterAdmin) {}\n\n  function addSwapperInternal(address _swapper) external {\n    _swappers.add(_swapper);\n  }\n\n  function removeSwapperInternal(address _swapper) external {\n    _swappers.remove(_swapper);\n  }\n\n}\n"
    },
    "contracts/swappers/sync/SushiswapPolygonSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';\nimport '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@openzeppelin/contracts/utils/math/Math.sol';\nimport '../../Swapper.sol';\n\ninterface ISushiswapPolygonSwapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function WMATIC() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function WETH() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_ROUTER() external view returns (address);\n}\n\ncontract SushiswapPolygonSwapper is ISushiswapPolygonSwapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public constant override SWAPPER_TYPE = SwapperType.SYNC;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override WETH;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override WMATIC;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _wmatic,\n    address _uniswapFactory,\n    address _uniswapRouter\n  ) Swapper(_governor, _tradeFactory) {\n    WETH = _weth;\n    WMATIC = _wmatic;\n    UNISWAP_FACTORY = _uniswapFactory;\n    UNISWAP_ROUTER = _uniswapRouter;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata\n  ) internal override returns (uint256 _receivedAmount) {\n    (address[] memory _path, uint256 _amountOut) = _getPathAndAmountOut(_tokenIn, _tokenOut, _amountIn);\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, 0);\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, _amountIn);\n    _receivedAmount = IUniswapV2Router02(UNISWAP_ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      _amountOut - ((_amountOut * _maxSlippage) / SLIPPAGE_PRECISION / 100), // slippage calcs\n      _path,\n      _receiver,\n      block.timestamp + 1800\n    )[_path.length - 1];\n  }\n\n  function _getPathAndAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) internal view returns (address[] memory _path, uint256 _amountOut) {\n    uint256 _amountOutByDirectPath;\n    address[] memory _directPath;\n    if (IUniswapV2Factory(UNISWAP_FACTORY).getPair(_tokenIn, _tokenOut) != address(0)) {\n      _directPath = new address[](2);\n      _directPath[0] = _tokenIn;\n      _directPath[1] = _tokenOut;\n      _amountOutByDirectPath = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _directPath)[1];\n    }\n\n    uint256 _amountOutByWETHHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WETHHopPath;\n    if (\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(_tokenIn, WETH) != address(0) &&\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(WETH, _tokenOut) != address(0)\n    ) {\n      _WETHHopPath = new address[](3);\n      _WETHHopPath[0] = _tokenIn;\n      _WETHHopPath[1] = WETH;\n      _WETHHopPath[2] = _tokenOut;\n      _amountOutByWETHHopPath = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _WETHHopPath)[2];\n    }\n\n    uint256 _amountOutByWMATICHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WMATICHopPath;\n    if (\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(_tokenIn, WMATIC) != address(0) &&\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(WMATIC, _tokenOut) != address(0)\n    ) {\n      _WMATICHopPath = new address[](3);\n      _WMATICHopPath[0] = _tokenIn;\n      _WMATICHopPath[1] = WMATIC;\n      _WMATICHopPath[2] = _tokenOut;\n      _amountOutByWMATICHopPath = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _WMATICHopPath)[2];\n    }\n\n    if (\n      Math.max(Math.max(_amountOutByDirectPath, _amountOutByWETHHopPath), Math.max(_amountOutByDirectPath, _amountOutByWMATICHopPath)) ==\n      _amountOutByDirectPath\n    ) {\n      return (_directPath, _amountOutByDirectPath);\n    }\n\n    if (Math.max(_amountOutByWETHHopPath, _amountOutByWMATICHopPath) == _amountOutByWETHHopPath) {\n      return (_WETHHopPath, _amountOutByWETHHopPath);\n    }\n\n    return (_WMATICHopPath, _amountOutByWMATICHopPath);\n  }\n}\n"
    },
    "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": {
      "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n    function removeLiquidityETHSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountETH);\n    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountETH);\n\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n    function swapExactETHForTokensSupportingFeeOnTransferTokens(\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external payable;\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n}\n"
    },
    "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Factory {\n    event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n    function feeTo() external view returns (address);\n    function feeToSetter() external view returns (address);\n\n    function getPair(address tokenA, address tokenB) external view returns (address pair);\n    function allPairs(uint) external view returns (address pair);\n    function allPairsLength() external view returns (uint);\n\n    function createPair(address tokenA, address tokenB) external returns (address pair);\n\n    function setFeeTo(address) external;\n    function setFeeToSetter(address) external;\n}\n"
    },
    "@openzeppelin/contracts/utils/math/Math.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow, so we distribute.\n        return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a / b + (a % b == 0 ? 0 : 1);\n    }\n}\n"
    },
    "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": {
      "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n    function factory() external pure returns (address);\n    function WETH() external pure returns (address);\n\n    function addLiquidity(\n        address tokenA,\n        address tokenB,\n        uint amountADesired,\n        uint amountBDesired,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB, uint liquidity);\n    function addLiquidityETH(\n        address token,\n        uint amountTokenDesired,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n    function removeLiquidity(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETH(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountToken, uint amountETH);\n    function removeLiquidityWithPermit(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETHWithPermit(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountToken, uint amountETH);\n    function swapExactTokensForTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapTokensForExactTokens(\n        uint amountOut,\n        uint amountInMax,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n\n    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n"
    },
    "contracts/OTCPool/OTCPoolTradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/utils/math/Math.sol';\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport '../TradeFactory/TradeFactorySwapperHandler.sol';\nimport '../OTCSwapper.sol';\nimport './OTCPoolDesk.sol';\n\ninterface IOTCPoolTradeable {\n  event TradeFactorySet(address indexed _tradeFactory);\n  event Claimed(address indexed _receiver, address _claimedToken, uint256 _amountClaimed);\n  event TradePerformed(\n    address indexed _swapper,\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _tookFromPool,\n    uint256 _tookFromSwapper\n  );\n\n  function tradeFactory() external view returns (address _tradeFactory);\n\n  function swappedAvailable(address _swappedToken) external view returns (uint256 _swappedAmount);\n\n  function setTradeFactory(address _tradeFactory) external;\n\n  function claim(address _token, uint256 _amount) external;\n\n  function takeOffer(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _offeredAmount\n  ) external returns (uint256 _tookFromPool, uint256 _tookFromSwapper);\n}\n\nabstract contract OTCPoolTradeable is IOTCPoolTradeable, OTCPoolDesk {\n  using SafeERC20 for IERC20;\n\n  address public override tradeFactory;\n  mapping(address => uint256) public override swappedAvailable;\n\n  constructor(address _tradeFactory) {\n    _setTradeFactory(_tradeFactory);\n  }\n\n  // this modifier allows any registered swapper to utilize OTC funds, this is not an idial design. TODO change.\n  modifier onlyRegisteredSwapper() {\n    require(ITradeFactorySwapperHandler(tradeFactory).isSwapper(msg.sender), 'OTCPool: unregistered swapper');\n    _;\n  }\n\n  function setTradeFactory(address _tradeFactory) external override onlyGovernor {\n    _setTradeFactory(_tradeFactory);\n  }\n\n  function _setTradeFactory(address _tradeFactory) internal {\n    require(_tradeFactory != address(0), 'OTCPool: zero address');\n    tradeFactory = _tradeFactory;\n    emit TradeFactorySet(_tradeFactory);\n  }\n\n  function claim(address _token, uint256 _amountToClaim) external override onlyOTCProvider {\n    require(msg.sender != address(0), 'OTCPool: zero address');\n    require(_token != address(0), 'OTCPool: zero address'); // TODO: can this be deprecated ? technically if token is zero, it wont have swapped available -- gas optimization\n    require(_amountToClaim <= swappedAvailable[_token], 'OTCPool: zero claim');\n    swappedAvailable[_token] -= _amountToClaim;\n    IERC20(_token).safeTransfer(msg.sender, _amountToClaim);\n    _subTokenUnderManagement(_token, _amountToClaim);\n    emit Claimed(msg.sender, _token, _amountToClaim);\n  }\n\n  function takeOffer(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _maxOfferedAmount\n  ) external override onlyRegisteredSwapper returns (uint256 _tookFromPool, uint256 _tookFromSwapper) {\n    if (availableFor[_wantedTokenFromPool][_offeredTokenToPool] == 0) return (0, 0);\n    (_tookFromPool, _tookFromSwapper) = _getMaxTakeableFromPoolAndSwapper(\n      msg.sender,\n      _offeredTokenToPool,\n      _wantedTokenFromPool,\n      _maxOfferedAmount\n    );\n    IERC20(_offeredTokenToPool).safeTransferFrom(msg.sender, address(this), _tookFromSwapper);\n    _addTokenUnderManagement(_offeredTokenToPool, _tookFromSwapper);\n    availableFor[_wantedTokenFromPool][_offeredTokenToPool] -= _tookFromPool;\n    swappedAvailable[_offeredTokenToPool] += _tookFromSwapper;\n    IERC20(_wantedTokenFromPool).safeTransfer(msg.sender, _tookFromPool);\n    _subTokenUnderManagement(_wantedTokenFromPool, _tookFromPool);\n    emit TradePerformed(msg.sender, _offeredTokenToPool, _wantedTokenFromPool, _tookFromPool, _tookFromSwapper);\n  }\n\n  function _getMaxTakeableFromPoolAndSwapper(\n    address _swapper,\n    address _offered,\n    address _wanted,\n    uint256 _offeredAmount\n  ) internal view virtual returns (uint256 _tookFromPool, uint256 _tookFromSwapper) {\n    uint256 _maxWantedFromOffered = IOTCSwapper(_swapper).getTotalAmountOut(_offered, _wanted, _offeredAmount);\n    _tookFromPool = Math.min(availableFor[_wanted][_offered], _maxWantedFromOffered);\n    _tookFromSwapper = IOTCSwapper(_swapper).getTotalAmountOut(_wanted, _offered, _tookFromPool);\n  }\n}\n"
    },
    "contracts/OTCSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport './OTCPool/OTCPool.sol';\nimport './Swapper.sol';\n\ninterface IOTCSwapper is ISwapper {\n  function getTotalAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) external view returns (uint256 _amountOut);\n\n  function OTC_POOL() external view returns (address);\n}\n\nabstract contract OTCSwapper is IOTCSwapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  address public immutable override OTC_POOL;\n\n  constructor(address _otcPool) {\n    OTC_POOL = _otcPool;\n  }\n\n  function getTotalAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) external view virtual override returns (uint256 _amountOut) {\n    _amountOut = _getTotalAmountOut(_tokenIn, _tokenOut, _amountIn);\n  }\n\n  function _getTotalAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) internal view virtual returns (uint256 _amountOut);\n\n  function swap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) external override(ISwapper, Swapper) onlyTradeFactory returns (uint256 _receivedAmount) {\n    _assertPreSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage);\n    IERC20(_tokenIn).safeTransferFrom(TRADE_FACTORY, address(this), _amountIn);\n    _receivedAmount = _executeOTCSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\n    emit Swapped(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _receivedAmount, _data);\n  }\n\n  function _executeOTCSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) internal returns (uint256 _receivedAmount) {\n    uint256 _usedBySwapper;\n\n    (_receivedAmount, _usedBySwapper) = IOTCPool(OTC_POOL).takeOffer(_tokenIn, _tokenOut, _amountIn);\n\n    // Buy what's missing from fallback swapper\n    if (_usedBySwapper < _amountIn) {\n      uint256 _toBuyFromFallbackSwapper = _amountIn - _usedBySwapper;\n\n      _receivedAmount += _executeSwap(_receiver, _tokenIn, _tokenOut, _toBuyFromFallbackSwapper, _maxSlippage, _data);\n    }\n  }\n}\n"
    },
    "contracts/OTCPool/OTCPoolDesk.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport '@lbertenasco/contract-utils/contracts/utils/Governable.sol';\n\nimport '../utils/CollectableDustWithTokensManagement.sol';\n\ninterface IOTCPoolDesk {\n  event OTCProviderSet(address indexed _OTCProvider);\n  event Deposited(address indexed _depositor, address _offeredTokenToPool, address _wantedTokenFromPool, uint256 _amountToOffer);\n  event Withdrew(address indexed _receiver, address _offeredTokenToPool, address _wantedTokenFromPool, uint256 _amountToWithdraw);\n\n  function OTCProvider() external view returns (address);\n\n  function availableFor(address _offeredToken, address _wantedtoken) external view returns (uint256 _offeredAmount);\n\n  function setOTCProvider(address _OTCProvider) external;\n\n  function deposit(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _amount\n  ) external;\n\n  function withdraw(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _amount\n  ) external;\n}\n\nabstract contract OTCPoolDesk is IOTCPoolDesk, CollectableDustWithTokensManagement, Governable {\n  using SafeERC20 for IERC20;\n\n  address public override OTCProvider;\n  mapping(address => mapping(address => uint256)) public override availableFor;\n\n  constructor(address _OTCProvider) {\n    _setOTCProvider(_OTCProvider);\n  }\n\n  modifier onlyOTCProvider() {\n    require(msg.sender == OTCProvider, 'OTCPool: unauthorized');\n    _;\n  }\n\n  function setOTCProvider(address _OTCProvider) external virtual override onlyGovernor {\n    _setOTCProvider(_OTCProvider);\n  }\n\n  function _setOTCProvider(address _OTCProvider) internal {\n    require(_OTCProvider != address(0), 'OTCPool: zero address');\n    OTCProvider = _OTCProvider;\n    emit OTCProviderSet(_OTCProvider);\n  }\n\n  function deposit(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _amount\n  ) public virtual override onlyOTCProvider {\n    require(_offeredTokenToPool != address(0) && _wantedTokenFromPool != address(0), 'OTCPool: tokens should not be zero');\n    require(_amount > 0, 'OTCPool: should provide more than zero');\n    IERC20(_offeredTokenToPool).safeTransferFrom(msg.sender, address(this), _amount);\n    availableFor[_offeredTokenToPool][_wantedTokenFromPool] += _amount;\n    _addTokenUnderManagement(_offeredTokenToPool, _amount);\n    emit Deposited(msg.sender, _offeredTokenToPool, _wantedTokenFromPool, _amount);\n  }\n\n  function withdraw(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _amount\n  ) public virtual override onlyOTCProvider {\n    require(_offeredTokenToPool != address(0) && _wantedTokenFromPool != address(0), 'OTCPool: tokens should not be zero');\n    require(_amount > 0, 'OTCPool: should withdraw more than zero');\n    require(availableFor[_offeredTokenToPool][_wantedTokenFromPool] >= _amount, 'OTCPool: not enough provided');\n    availableFor[_offeredTokenToPool][_wantedTokenFromPool] -= _amount;\n    IERC20(_offeredTokenToPool).safeTransfer(msg.sender, _amount);\n    _subTokenUnderManagement(_offeredTokenToPool, _amount);\n    emit Withdrew(msg.sender, _offeredTokenToPool, _wantedTokenFromPool, _amount);\n  }\n}\n"
    },
    "contracts/OTCPool/OTCPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../utils/CollectableDustWithTokensManagement.sol';\nimport './OTCPoolTradeable.sol';\nimport './OTCPoolDesk.sol';\n\ninterface IOTCPool is IOTCPoolTradeable {}\n\ncontract OTCPool is IOTCPool, CollectableDustWithTokensManagement, Governable, OTCPoolDesk, OTCPoolTradeable {\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _OTCProvider\n  ) Governable(_governor) OTCPoolDesk(_OTCProvider) OTCPoolTradeable(_tradeFactory) {}\n\n  // CollectableDustWithTokenManagement\n  function sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) external override onlyGovernor {\n    _sendDust(_to, _token, _amount);\n  }\n}\n"
    },
    "contracts/utils/CollectableDustWithTokensManagement.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@lbertenasco/contract-utils/interfaces/utils/ICollectableDust.sol';\n\ninterface ICollectableDustWithTokensManagement is ICollectableDust {}\n\nabstract contract CollectableDustWithTokensManagement is ICollectableDustWithTokensManagement {\n  using SafeERC20 for IERC20;\n\n  mapping(address => uint256) internal _tokensUnderManagement;\n\n  function _addTokenUnderManagement(address _token, uint256 _amount) internal {\n    require(\n      _tokensUnderManagement[_token] + _amount <= IERC20(_token).balanceOf(address(this)),\n      'CollectableDust: cant manage more than balance'\n    );\n    _tokensUnderManagement[_token] += _amount;\n  }\n\n  function _subTokenUnderManagement(address _token, uint256 _amount) internal {\n    require(_tokensUnderManagement[_token] >= _amount, 'CollectableDust: subtracting more than managed');\n    _tokensUnderManagement[_token] -= _amount;\n  }\n\n  function _sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) internal {\n    require(_to != address(0), 'CollectableDust: zero address');\n    require(_amount <= IERC20(_token).balanceOf(address(this)) - _tokensUnderManagement[_token], 'CollectableDust: taking more than dust');\n    IERC20(_token).safeTransfer(_to, _amount);\n    emit DustSent(_to, _token, _amount);\n  }\n}\n"
    },
    "contracts/mock/utils/CollectableDustWithTokensManagement.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../utils/CollectableDustWithTokensManagement.sol';\n\ncontract CollectableDustWithTokensManagementMock is CollectableDustWithTokensManagement{\n  constructor() {}\n\n  function tokensUnderManagement(address _token) external view returns (uint256) {\n    return _tokensUnderManagement[_token];\n  }\n\n  function addTokenUnderManagement(address _token, uint256 _amount) external {\n    _addTokenUnderManagement(_token, _amount);\n  }\n\n  function subTokenUnderManagement(address _token, uint256 _amount) external {\n    _subTokenUnderManagement(_token, _amount);\n  }\n\n  function sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) external override {\n    _sendDust(_to, _token, _amount);\n  }\n}"
    },
    "contracts/mock/OTCPool/OTCPoolDesk.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../OTCPool/OTCPoolDesk.sol';\n\nimport '../utils/CollectableDustWithTokensManagement.sol';\n\ncontract OTCPoolDeskMock is OTCPoolDesk, CollectableDustWithTokensManagementMock {\n\n  constructor(address _OTCProvider) OTCPoolDesk(_OTCProvider) Governable(msg.sender) {}\n\n  function onlyOTCProviderModifier() onlyOTCProvider external {}\n\n  function setAvailableFor(\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _amountToOffer\n  ) external {\n    availableFor[_offeredTokenToPool][_wantedTokenFromPool] = _amountToOffer;\n  }\n}\n"
    },
    "contracts/mock/OTCPool/OTCPoolTradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport './OTCPoolDesk.sol';\nimport '../../OTCPool/OTCPoolTradeable.sol';\n\ncontract OTCPoolTradeableMock is OTCPoolTradeable, OTCPoolDeskMock {\n\n  bool mockedGetMaxTakeableFromPoolAndSwapper;\n  uint256 tookFromPool;\n  uint256 tookFromSwapper;\n\n  constructor(address _OTCProvider, address _tradeFactory) OTCPoolTradeable(_tradeFactory) OTCPoolDeskMock(_OTCProvider) {}\n\n  function onlyRegisteredSwapperModifier() external onlyRegisteredSwapper {}\n\n  function setSwappedAvailable(\n    address _token,\n    uint256 _amount\n  ) external {\n    swappedAvailable[_token] = _amount;\n  }\n\n  function mockGetMaxTakeableFromPoolAndSwapper(\n    uint256 _tookFromPool, \n    uint256 _tookFromSwapper\n  ) external {\n    mockedGetMaxTakeableFromPoolAndSwapper = true;\n    tookFromPool = _tookFromPool;\n    tookFromSwapper = _tookFromSwapper;\n  }\n\n  function _getMaxTakeableFromPoolAndSwapper(\n    address _swapper,\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _maxOfferedAmount\n  ) internal override view returns (uint256 _tookFromPool, uint256 _tookFromSwapper) {\n    if (mockedGetMaxTakeableFromPoolAndSwapper) {\n      return (tookFromPool, tookFromSwapper);\n    } else {\n      return super._getMaxTakeableFromPoolAndSwapper(\n        _swapper,\n        _offeredTokenToPool,\n        _wantedTokenFromPool,\n        _maxOfferedAmount\n      );\n    }\n  }\n\n  function getMaxTakeableFromPoolAndSwapper(\n    address _swapper,\n    address _offeredTokenToPool,\n    address _wantedTokenFromPool,\n    uint256 _maxOfferedAmount\n  ) external view returns (uint256 _tookFromPool, uint256 _tookFromSwapper) {\n    return _getMaxTakeableFromPoolAndSwapper(_swapper, _offeredTokenToPool, _wantedTokenFromPool, _maxOfferedAmount);\n  }\n}\n"
    },
    "contracts/swappers/sync/UniswapV2Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';\nimport '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '../../Swapper.sol';\n\ninterface IUniswapV2Swapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function WETH() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_ROUTER() external view returns (address);\n}\n\ncontract UniswapV2Swapper is IUniswapV2Swapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public constant override SWAPPER_TYPE = SwapperType.SYNC;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override WETH;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _uniswapFactory,\n    address _uniswapRouter\n  ) Swapper(_governor, _tradeFactory) {\n    WETH = _weth;\n    UNISWAP_FACTORY = _uniswapFactory;\n    UNISWAP_ROUTER = _uniswapRouter;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata\n  ) internal override returns (uint256 _receivedAmount) {\n    (address[] memory _path, uint256 _amountOut) = _getPathAndAmountOut(_tokenIn, _tokenOut, _amountIn);\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, 0);\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, _amountIn);\n    _receivedAmount = IUniswapV2Router02(UNISWAP_ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      _amountOut - ((_amountOut * _maxSlippage) / SLIPPAGE_PRECISION / 100), // slippage calcs\n      _path,\n      _receiver,\n      block.timestamp\n    )[_path.length - 1];\n  }\n\n  function _getPathAndAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) internal view returns (address[] memory _path, uint256 _amountOut) {\n    uint256 _amountOutByDirectPath;\n    address[] memory _directPath;\n\n    if (IUniswapV2Factory(UNISWAP_FACTORY).getPair(_tokenIn, _tokenOut) != address(0)) {\n      _directPath = new address[](2);\n      _directPath[0] = _tokenIn;\n      _directPath[1] = _tokenOut;\n      _amountOutByDirectPath = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _directPath)[1];\n    }\n\n    uint256 _amountOutByWETHHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WETHHopPath;\n    if (\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(_tokenIn, WETH) != address(0) &&\n      IUniswapV2Factory(UNISWAP_FACTORY).getPair(WETH, _tokenOut) != address(0)\n    ) {\n      _WETHHopPath = new address[](3);\n      _WETHHopPath[0] = _tokenIn;\n      _WETHHopPath[1] = WETH;\n      _WETHHopPath[2] = _tokenOut;\n      _amountOutByWETHHopPath = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _WETHHopPath)[2];\n    }\n\n    if (_amountOutByDirectPath >= _amountOutByWETHHopPath) return (_directPath, _amountOutByDirectPath);\n\n    return (_WETHHopPath, _amountOutByWETHHopPath);\n  }\n}\n"
    },
    "contracts/swappers/async/UniswapV2Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';\nimport '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '../../Swapper.sol';\n\ninterface IUniswapV2Swapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function WETH() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function UNISWAP_ROUTER() external view returns (address);\n}\n\ncontract UniswapV2Swapper is IUniswapV2Swapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public override SWAPPER_TYPE = SwapperType.ASYNC;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override WETH;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override UNISWAP_ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _uniswapFactory,\n    address _uniswapRouter\n  ) Swapper(_governor, _tradeFactory) {\n    WETH = _weth;\n    UNISWAP_FACTORY = _uniswapFactory;\n    UNISWAP_ROUTER = _uniswapRouter;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) internal override returns (uint256 _receivedAmount) {\n    address[] memory _path = abi.decode(_data, (address[]));\n    require(_tokenIn == _path[0] && _tokenOut == _path[_path.length - 1], 'Swapper: incorrect swap information');\n    uint256 _amountOut = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(_amountIn, _path)[_path.length - 1];\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, 0);\n    IERC20(_path[0]).safeApprove(UNISWAP_ROUTER, _amountIn);\n    _receivedAmount = IUniswapV2Router02(UNISWAP_ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      _amountOut - ((_amountOut * _maxSlippage) / SLIPPAGE_PRECISION / 100), // slippage calcs\n      _path,\n      _receiver,\n      block.timestamp\n    )[_path.length - 1];\n  }\n}\n"
    },
    "contracts/swappers/sync/otcs/OTCAndUniswapV2SyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '../../../OTCSwapper.sol';\nimport '../UniswapV2Swapper.sol';\n\ninterface IOTCAndUniswapV2Swapper is IOTCSwapper, IUniswapV2Swapper {}\n\ncontract OTCAndUniswapV2Swapper is IOTCAndUniswapV2Swapper, OTCSwapper, UniswapV2Swapper {\n  using SafeERC20 for IERC20;\n\n  constructor(\n    address _otcPool,\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _uniswapFactory,\n    address _uniswapRouter\n  ) OTCSwapper(_otcPool) UniswapV2Swapper(_governor, _tradeFactory, _weth, _uniswapFactory, _uniswapRouter) {}\n\n  function _getTotalAmountOut(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn\n  ) internal view override returns (uint256 _amountOut) {\n    (, _amountOut) = _getPathAndAmountOut(_tokenIn, _tokenOut, _amountIn);\n  }\n}\n"
    },
    "contracts/swappers/async/ZRXSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../Swapper.sol';\n\ninterface IZRXSwapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function ZRX() external view returns (address);\n}\n\ncontract ZRXSwapper is IZRXSwapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public constant override SWAPPER_TYPE = SwapperType.ASYNC;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override ZRX;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    // solhint-disable-next-line var-name-mixedcase\n    address _ZRX\n  ) Swapper(_governor, _tradeFactory) {\n    ZRX = _ZRX;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256, // Max slippage is used off-chain\n    bytes calldata _data\n  ) internal override returns (uint256 _receivedAmount) {\n    uint256 _initialBalanceTokenIn = IERC20(_tokenIn).balanceOf(address(this));\n    uint256 _initialBalanceOfTokenOut = IERC20(_tokenOut).balanceOf(address(this));\n    IERC20(_tokenIn).safeApprove(ZRX, _amountIn);\n    (bool success, ) = ZRX.call{value: 0}(_data);\n    require(success, 'Swapper: ZRX trade reverted');\n    // Check that token in & amount in was correct\n    require(_initialBalanceTokenIn - IERC20(_tokenIn).balanceOf(address(this)) >= _amountIn, 'Swapper: incorrect swap information');\n    // Check that token out was correct\n    uint256 _finalBalanceOfTokenOut = IERC20(_tokenOut).balanceOf(address(this));\n    _receivedAmount = _finalBalanceOfTokenOut - _initialBalanceOfTokenOut;\n    require(_receivedAmount > 0, 'Swapper: incorrect swap information');\n    IERC20(_tokenOut).safeTransfer(_receiver, _receivedAmount);\n  }\n}\n"
    },
    "contracts/swappers/async/OneInchAggregatorSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../Swapper.sol';\n\ninterface IAggregationExecutor {\n  function callBytes(bytes calldata data) external payable;\n}\n\ninterface IOneInchExchange {\n  struct SwapDescription {\n    IERC20 srcToken;\n    IERC20 dstToken;\n    address srcReceiver;\n    address dstReceiver;\n    uint256 amount;\n    uint256 minReturnAmount;\n    uint256 flags;\n    bytes permit;\n  }\n\n  event Swapped(address sender, IERC20 srcToken, IERC20 dstToken, address dstReceiver, uint256 spentAmount, uint256 returnAmount);\n\n  function unoswapWithPermit(\n    IERC20 srcToken,\n    uint256 amount,\n    uint256 minReturn,\n    bytes32[] calldata pools,\n    bytes calldata permit\n  ) external payable returns (uint256 returnAmount);\n\n  function unoswap(\n    IERC20 srcToken,\n    uint256 amount,\n    uint256 minReturn,\n    bytes32[] calldata\n  ) external payable returns (uint256 returnAmount);\n\n  function discountedSwap(\n    IAggregationExecutor caller,\n    SwapDescription calldata desc,\n    bytes calldata data\n  )\n    external\n    payable\n    returns (\n      uint256 returnAmount,\n      uint256 gasLeft,\n      uint256 chiSpent\n    );\n\n  function swap(\n    IAggregationExecutor caller,\n    SwapDescription calldata desc,\n    bytes calldata data\n  ) external payable returns (uint256 returnAmount, uint256 gasLeft);\n}\n\ninterface IOneInchAggregatorSwapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function AGGREGATION_ROUTER_V3() external view returns (address);\n}\n\ncontract OneInchAggregatorSwapper is IOneInchAggregatorSwapper, Swapper {\n  using SafeERC20 for IERC20;\n\n  uint256 private constant _SHOULD_CLAIM_FLAG = 0x04;\n\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public constant override SWAPPER_TYPE = SwapperType.ASYNC;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override AGGREGATION_ROUTER_V3;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _aggregationRouter\n  ) Swapper(_governor, _tradeFactory) {\n    AGGREGATION_ROUTER_V3 = _aggregationRouter;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256, // Max slippage is used off-chain\n    bytes calldata _data\n  ) internal override returns (uint256 _receivedAmount) {\n    (IAggregationExecutor _caller, IOneInchExchange.SwapDescription memory _swapDescription, bytes memory _tradeData) = abi.decode(\n      _data[4:],\n      (IAggregationExecutor, IOneInchExchange.SwapDescription, bytes)\n    );\n    require(\n      _swapDescription.dstReceiver == _receiver &&\n        address(_swapDescription.srcToken) == _tokenIn &&\n        address(_swapDescription.dstToken) == _tokenOut &&\n        _swapDescription.amount == _amountIn &&\n        _swapDescription.flags == _SHOULD_CLAIM_FLAG,\n      'Swapper: incorrect swap information'\n    );\n    IERC20(_tokenIn).safeApprove(AGGREGATION_ROUTER_V3, 0);\n    IERC20(_tokenIn).safeApprove(AGGREGATION_ROUTER_V3, _amountIn);\n    (_receivedAmount, ) = IOneInchExchange(AGGREGATION_ROUTER_V3).swap(_caller, _swapDescription, _tradeData);\n  }\n}\n"
    },
    "contracts/mock/Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../Swapper.sol';\n\ncontract SwapperMock is Swapper {\n\n  event MyInternalExecuteSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes _data\n  );\n\n  event DecodedData(uint256 _decodedData);\n  \n  constructor(address _governor, address _tradeFactory) Swapper(_governor, _tradeFactory) {}\n\n  function SWAPPER_TYPE() external view override returns (SwapperType) {\n    return SwapperType.ASYNC;\n  }\n\n  function modifierOnlyTradeFactory() external onlyTradeFactory { }\n\n  function assertPreSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage\n  ) external pure {\n    _assertPreSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage);\n  }\n\n  function _decodeData(bytes calldata _data) internal pure returns (uint256) {\n    return abi.decode(_data, (uint256));\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage,\n    bytes calldata _data\n  ) internal override returns (uint256 _receivedAmount) {\n    uint256 _decodedData = _decodeData(_data);\n    emit DecodedData(_decodedData);\n    emit MyInternalExecuteSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\n    _receivedAmount = 1_000;\n  }\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactoryExecutor.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.4;\n\nimport '../../TradeFactory/TradeFactoryExecutor.sol';\nimport './TradeFactoryPositionsHandler.sol';\n\ncontract TradeFactoryExecutorMock is TradeFactoryPositionsHandlerMock, TradeFactoryExecutor {\n  constructor(\n    address _masterAdmin, \n    address _swapperAdder, \n    address _swapperSetter, \n    address _strategyAdder, \n    address _mechanicsRegistry\n  ) \n    TradeFactoryPositionsHandlerMock(_masterAdmin, _swapperAdder, _swapperSetter, _strategyAdder)\n    TradeFactoryExecutor(_mechanicsRegistry) {}\n\n  function enableSwapperToken(address _swapper, address _token) external {\n    _enableSwapperToken(_swapper, _token);\n  }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "storageLayout",
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "evm.gasEstimates"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {
      "": {
        "__CACHE_BREAKER__": "0x00000000d41867734bbee4c6863d9255b2b06ac1"
      }
    }
  }
}