{
  "language": "Solidity",
  "sources": {
    "contracts/interfaces/IWETH.sol": {
      "content": "pragma solidity >=0.5.0;\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\ninterface IWETH is IERC20 {\n  function deposit() external payable;\n\n  function withdraw(uint256) external;\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"
    },
    "contracts/swappers/sync/BancorSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport './SyncSwapper.sol';\n\ninterface IContractRegistry {\n  function addressOf(bytes32 contractName) external returns (address);\n}\n\ninterface IBancorNetwork {\n  function convertByPath(\n    address[] memory _path,\n    uint256 _amount,\n    uint256 _minReturn,\n    address _beneficiary,\n    address _affiliateAccount,\n    uint256 _affiliateFee\n  ) external payable returns (uint256);\n\n  function rateByPath(address[] memory _path, uint256 _amount) external view returns (uint256);\n\n  function conversionPath(address _sourceToken, address _targetToken) external view returns (address[] memory);\n\n  function convert(\n    address[] memory path,\n    uint256 amount,\n    uint256 minReturn\n  ) external payable returns (uint256 returnAmount);\n}\n\ninterface IBancorSwapper is ISyncSwapper {\n  function contractRegistry() external returns (IContractRegistry);\n\n  function bancorNetworkName() external returns (bytes32);\n}\n\ncontract BancorSwapper is IBancorSwapper, SyncSwapper {\n  using SafeERC20 for IERC20;\n\n  IContractRegistry public immutable override contractRegistry;\n  bytes32 public immutable override bancorNetworkName;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    IContractRegistry _contractRegistry,\n    bytes32 _bancorNetworkName\n  ) SyncSwapper(_governor, _tradeFactory) {\n    contractRegistry = _contractRegistry;\n    bancorNetworkName = _bancorNetworkName;\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 {\n    IBancorNetwork _bancorNetwork = IBancorNetwork(contractRegistry.addressOf(bancorNetworkName));\n    address[] memory _path = _bancorNetwork.conversionPath(_tokenIn, _tokenOut);\n    uint256 _minReturn = _bancorNetwork.rateByPath(_path, _amountIn);\n    _minReturn = _minReturn - ((_minReturn * _maxSlippage) / SLIPPAGE_PRECISION / 100); // slippage calcs\n    IERC20(_tokenIn).approve(address(_bancorNetwork), 0);\n    IERC20(_tokenIn).approve(address(_bancorNetwork), _amountIn);\n    IERC20(_tokenOut).safeTransfer(_receiver, _bancorNetwork.convert(_path, _amountIn, _minReturn));\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"
    },
    "contracts/swappers/sync/SyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '../Swapper.sol';\n\ninterface ISyncSwapper is ISwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function SLIPPAGE_PRECISION() external view returns (uint256);\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;\n}\n\nabstract contract SyncSwapper is ISyncSwapper, Swapper {\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  SwapperType public constant override SWAPPER_TYPE = SwapperType.SYNC;\n\n  constructor(address _governor, address _tradeFactory) Governable(_governor) Swapper(_tradeFactory) {}\n\n  function _assertPreSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256\n  ) internal pure {\n    if (_receiver == address(0) || _tokenIn == address(0) || _tokenOut == address(0)) revert CommonErrors.ZeroAddress();\n    if (_amountIn == 0) revert CommonErrors.ZeroAmount();\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;\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 {\n    _assertPreSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage);\n    _executeSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _maxSlippage, _data);\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    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/swappers/Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport '@yearn-contracts/contract-utils/solidity/contracts/utils/Governable.sol';\nimport '@yearn-contracts/contract-utils/solidity/contracts/utils/CollectableDust.sol';\n\nimport '../CommonErrors.sol';\n\ninterface ISwapper {\n  event TradeFactorySet(address _tradeFactory);\n\n  enum SwapperType {\n    ASYNC,\n    SYNC\n  }\n\n  // solhint-disable-next-line func-name-mixedcase\n  function SWAPPER_TYPE() external view returns (SwapperType);\n\n  function tradeFactory() external view returns (address);\n\n  function setTradeFactory(address _tradeFactory) external;\n}\n\nabstract contract Swapper is ISwapper, Governable, CollectableDust {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public override tradeFactory;\n\n  constructor(address _tradeFactory) {\n    if (_tradeFactory == address(0)) revert CommonErrors.ZeroAddress();\n    tradeFactory = _tradeFactory;\n  }\n\n  function setTradeFactory(address _tradeFactory) external override onlyGovernor {\n    if (_tradeFactory == address(0)) revert CommonErrors.ZeroAddress();\n    tradeFactory = _tradeFactory;\n    emit TradeFactorySet(_tradeFactory);\n  }\n\n  modifier onlyTradeFactory() {\n    if (msg.sender != tradeFactory) revert CommonErrors.NotAuthorized();\n    _;\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"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/utils/Governable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/utils/CollectableDust.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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 contract 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/CommonErrors.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nlibrary CommonErrors {\n  error ZeroAddress();\n  error NotAuthorized();\n  error ZeroAmount();\n  error ZeroSlippage();\n  error IncorrectSwapInformation();\n}\n"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/interfaces/utils/IGovernable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\ninterface IGovernable {\n  event PendingGovernorSet(address pendingGovernor);\n  event GovernorAccepted();\n\n  function setPendingGovernor(address _pendingGovernor) external;\n\n  function acceptGovernor() external;\n\n  function governor() external view returns (address _governor);\n\n  function pendingGovernor() external view returns (address _pendingGovernor);\n\n  function isGovernor(address _account) external view returns (bool _isGovernor);\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    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\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    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        return _values(set._inner);\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    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        assembly {\n            result := store\n        }\n\n        return result;\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    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/interfaces/utils/ICollectableDust.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\ninterface ICollectableDust {\n  event DustSent(address _to, address token, uint256 amount);\n\n  function sendDust(\n    address _to,\n    address _token,\n    uint256 _amount\n  ) external;\n}\n"
    },
    "contracts/swappers/sync/UniswapV2Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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';\n\nimport './SyncSwapper.sol';\n\ninterface IUniswapV2Swapper is ISyncSwapper {\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 FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function ROUTER() external view returns (address);\n}\n\ncontract UniswapV2Swapper is IUniswapV2Swapper, SyncSwapper {\n  using SafeERC20 for IERC20;\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 FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _factory,\n    address _router\n  ) SyncSwapper(_governor, _tradeFactory) {\n    WETH = _weth;\n    FACTORY = _factory;\n    ROUTER = _router;\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 {\n    address[] memory _path;\n    uint256 _amountOut;\n    if (_data.length > 0) {\n      _path = abi.decode(_data, (address[]));\n      _amountOut = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _path)[_path.length - 1];\n    } else {\n      (_path, _amountOut) = _getPathAndAmountOut(_tokenIn, _tokenOut, _amountIn);\n    }\n    IERC20(_path[0]).approve(ROUTER, 0);\n    IERC20(_path[0]).approve(ROUTER, _amountIn);\n    IUniswapV2Router02(ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      _amountOut - ((_amountOut * _maxSlippage) / SLIPPAGE_PRECISION / 100), // slippage calcs\n      _path,\n      _receiver,\n      block.timestamp\n    );\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(FACTORY).getPair(_tokenIn, _tokenOut) != address(0)) {\n      _directPath = new address[](2);\n      _directPath[0] = _tokenIn;\n      _directPath[1] = _tokenOut;\n      _amountOutByDirectPath = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _directPath)[1];\n    }\n\n    uint256 _amountOutByWETHHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WETHHopPath;\n    if (IUniswapV2Factory(FACTORY).getPair(_tokenIn, WETH) != address(0) && IUniswapV2Factory(FACTORY).getPair(WETH, _tokenOut) != address(0)) {\n      _WETHHopPath = new address[](3);\n      _WETHHopPath[0] = _tokenIn;\n      _WETHHopPath[1] = WETH;\n      _WETHHopPath[2] = _tokenOut;\n      _amountOutByWETHHopPath = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _WETHHopPath)[2];\n    }\n\n    if (_amountOutByDirectPath >= _amountOutByWETHHopPath) return (_directPath, _amountOutByDirectPath);\n\n    return (_WETHHopPath, _amountOutByWETHHopPath);\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"
    },
    "@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/utils/SwapperEnabled.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport './ISwapperEnabled.sol';\nimport {ITradeFactoryExecutor} from '../TradeFactory/TradeFactoryExecutor.sol';\nimport {ITradeFactoryPositionsHandler} from '../TradeFactory/TradeFactoryPositionsHandler.sol';\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    // strategy should handle disabling all previous trades and creating all new ones\n    tradeFactory = _tradeFactory;\n  }\n\n  // onlyMultisig or internal use:\n  function _enableTrade(address _tokenIn, address _tokenOut) internal {\n    IERC20(_tokenIn).approve(tradeFactory, type(uint256).max);\n    return ITradeFactoryPositionsHandler(tradeFactory).enable(_tokenIn, _tokenOut);\n  }\n\n  function disableTradeCallback(address _tokenIn, address _tokenOut) external override {\n    if (msg.sender != tradeFactory) revert NotTradeFactory();\n    IERC20(_tokenIn).approve(tradeFactory, 0);\n    ITradeFactoryPositionsHandler(tradeFactory).disable(_tokenIn, _tokenOut);\n  }\n\n  function _disableTrade(address _tokenIn, address _tokenOut) internal {\n    IERC20(_tokenIn).approve(tradeFactory, 0);\n    ITradeFactoryPositionsHandler(tradeFactory).disable(_tokenIn, _tokenOut);\n  }\n\n  function _executeTrade(\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _maxSlippage\n  ) internal returns (uint256 _receivedAmount) {\n    return\n      ITradeFactoryExecutor(tradeFactory).execute(\n        ITradeFactoryExecutor.SyncTradeExecutionDetails(_tokenIn, _tokenOut, _amountIn, _maxSlippage),\n        ''\n      );\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    return\n      ITradeFactoryExecutor(tradeFactory).execute(\n        ITradeFactoryExecutor.SyncTradeExecutionDetails(_tokenIn, _tokenOut, _amountIn, _maxSlippage),\n        _data\n      );\n  }\n}\n"
    },
    "contracts/utils/ISwapperEnabled.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.4 <0.9.0;\n\ninterface ISwapperEnabled {\n  error NotTradeFactory();\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 enableTrade(address _tokenIn, address _tokenOut) external;\n\n  function disableTrade(address _tokenIn, address _tokenOut) external;\n\n  function disableTradeCallback(address _tokenIn, address _tokenOut) external;\n}\n"
    },
    "contracts/TradeFactory/TradeFactoryExecutor.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/utils/math/Math.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol';\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '@yearn-contracts/contract-utils/solidity/contracts/utils/Machinery.sol';\n\nimport '../swappers/async/AsyncSwapper.sol';\nimport '../swappers/async/MultipleAsyncSwapper.sol';\nimport '../swappers/sync/SyncSwapper.sol';\n\nimport './TradeFactoryPositionsHandler.sol';\n\ninterface ITradeFactoryExecutor {\n  event SyncTradeExecuted(address indexed _strategy, uint256 _receivedAmount, address indexed _swapper);\n\n  event AsyncTradeExecuted(uint256 _receivedAmount, address _swapper);\n\n  event MultipleAsyncTradeExecuted(uint256[] _receivedAmount, address _swapper);\n\n  error InvalidAmountOut();\n\n  struct SyncTradeExecutionDetails {\n    address _tokenIn;\n    address _tokenOut;\n    uint256 _amountIn;\n    uint256 _maxSlippage;\n  }\n\n  struct AsyncTradeExecutionDetails {\n    address _strategy;\n    address _tokenIn;\n    address _tokenOut;\n    uint256 _amount;\n    uint256 _minAmountOut;\n  }\n\n  // Sync execution\n  function execute(SyncTradeExecutionDetails calldata _tradeExecutionDetails, bytes calldata _data) external returns (uint256 _receivedAmount);\n\n  // Async execution\n  function execute(\n    AsyncTradeExecutionDetails calldata _tradeExecutionDetails,\n    address _swapper,\n    bytes calldata _data\n  ) external returns (uint256 _receivedAmount);\n\n  // Multiple async execution\n  function execute(\n    AsyncTradeExecutionDetails[] calldata _tradesExecutionDetails,\n    address _swapper,\n    bytes calldata _data\n  ) external;\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  // Machinery\n  function setMechanicsRegistry(address __mechanicsRegistry) external virtual override onlyRole(MASTER_ADMIN) {\n    _setMechanicsRegistry(__mechanicsRegistry);\n  }\n\n  // Execute via sync swapper\n  function execute(SyncTradeExecutionDetails calldata _tradeExecutionDetails, bytes calldata _data)\n    external\n    override\n    onlyRole(STRATEGY)\n    returns (uint256 _receivedAmount)\n  {\n    address _swapper = strategySyncSwapper[msg.sender];\n    if (_tradeExecutionDetails._tokenIn == address(0) || _tradeExecutionDetails._tokenOut == address(0)) revert CommonErrors.ZeroAddress();\n    if (_tradeExecutionDetails._amountIn == 0) revert CommonErrors.ZeroAmount();\n    if (_tradeExecutionDetails._maxSlippage == 0) revert CommonErrors.ZeroSlippage();\n    IERC20(_tradeExecutionDetails._tokenIn).safeTransferFrom(msg.sender, _swapper, _tradeExecutionDetails._amountIn);\n    uint256 _preSwapBalanceOut = IERC20(_tradeExecutionDetails._tokenOut).balanceOf(msg.sender);\n    ISyncSwapper(_swapper).swap(\n      msg.sender,\n      _tradeExecutionDetails._tokenIn,\n      _tradeExecutionDetails._tokenOut,\n      _tradeExecutionDetails._amountIn,\n      _tradeExecutionDetails._maxSlippage,\n      _data\n    );\n    _receivedAmount = IERC20(_tradeExecutionDetails._tokenOut).balanceOf(msg.sender) - _preSwapBalanceOut;\n    emit SyncTradeExecuted(msg.sender, _receivedAmount, _swapper);\n  }\n\n  // Execute via async swapper\n  function execute(\n    AsyncTradeExecutionDetails calldata _tradeExecutionDetails,\n    address _swapper,\n    bytes calldata _data\n  ) external override onlyMechanic returns (uint256 _receivedAmount) {\n    if (\n      !_tokensOutByStrategyAndTokenIn[_tradeExecutionDetails._strategy][_tradeExecutionDetails._tokenIn].contains(\n        _tradeExecutionDetails._tokenOut\n      )\n    ) revert InvalidTrade();\n    if (!_swappers.contains(_swapper)) revert InvalidSwapper();\n    uint256 _amount = _tradeExecutionDetails._amount != 0\n      ? _tradeExecutionDetails._amount\n      : IERC20(_tradeExecutionDetails._tokenIn).balanceOf(_tradeExecutionDetails._strategy);\n    IERC20(_tradeExecutionDetails._tokenIn).safeTransferFrom(_tradeExecutionDetails._strategy, _swapper, _amount);\n    uint256 _preSwapBalanceOut = IERC20(_tradeExecutionDetails._tokenOut).balanceOf(_tradeExecutionDetails._strategy);\n    IAsyncSwapper(_swapper).swap(\n      _tradeExecutionDetails._strategy,\n      _tradeExecutionDetails._tokenIn,\n      _tradeExecutionDetails._tokenOut,\n      _amount,\n      _tradeExecutionDetails._minAmountOut,\n      _data\n    );\n    _receivedAmount = IERC20(_tradeExecutionDetails._tokenOut).balanceOf(_tradeExecutionDetails._strategy) - _preSwapBalanceOut;\n    if (_receivedAmount < _tradeExecutionDetails._minAmountOut) revert InvalidAmountOut();\n    emit AsyncTradeExecuted(_receivedAmount, _swapper);\n  }\n\n  function execute(\n    AsyncTradeExecutionDetails[] calldata _tradesExecutionDetails,\n    address _swapper,\n    bytes calldata _data\n  ) external override onlyMechanic {\n    // Balance out holder will firstly have the pre swap balance out of each strategy\n    uint256[] memory _balanceOutHolder = new uint256[](_tradesExecutionDetails.length);\n    if (!_swappers.contains(_swapper)) revert InvalidSwapper();\n    for (uint256 i; i < _tradesExecutionDetails.length; i++) {\n      if (\n        !_tokensOutByStrategyAndTokenIn[_tradesExecutionDetails[i]._strategy][_tradesExecutionDetails[i]._tokenIn].contains(\n          _tradesExecutionDetails[i]._tokenOut\n        )\n      ) revert InvalidTrade();\n      uint256 _amount = _tradesExecutionDetails[i]._amount != 0\n        ? _tradesExecutionDetails[i]._amount\n        : IERC20(_tradesExecutionDetails[i]._tokenIn).balanceOf(_tradesExecutionDetails[i]._strategy);\n      IERC20(_tradesExecutionDetails[i]._tokenIn).safeTransferFrom(_tradesExecutionDetails[i]._strategy, _swapper, _amount);\n      _balanceOutHolder[i] = IERC20(_tradesExecutionDetails[i]._tokenOut).balanceOf(_tradesExecutionDetails[i]._strategy);\n    }\n    IMultipleAsyncSwapper(_swapper).swapMultiple(_data);\n    for (uint256 i; i < _tradesExecutionDetails.length; i++) {\n      // Balance out holder will now store the total received amount of token out per strat\n      _balanceOutHolder[i] = IERC20(_tradesExecutionDetails[i]._tokenOut).balanceOf(_tradesExecutionDetails[i]._strategy) - _balanceOutHolder[i];\n      if (_balanceOutHolder[i] < _tradesExecutionDetails[i]._minAmountOut) revert InvalidAmountOut();\n    }\n    emit MultipleAsyncTradeExecuted(_balanceOutHolder, _swapper);\n  }\n}\n"
    },
    "contracts/TradeFactory/TradeFactoryPositionsHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\nimport './TradeFactorySwapperHandler.sol';\n\nimport {ISwapperEnabled} from '../utils/ISwapperEnabled.sol';\n\ninterface ITradeFactoryPositionsHandler {\n  struct EnabledTrade {\n    address _strategy;\n    address _tokenIn;\n    address _tokenOut;\n  }\n\n  error InvalidTrade();\n\n  error AllowanceShouldBeZero();\n\n  function enabledTrades() external view returns (EnabledTrade[] memory _enabledTrades);\n\n  function enable(address _tokenIn, address _tokenOut) external;\n\n  function disable(address _tokenIn, address _tokenOut) external;\n\n  function disableByAdmin(\n    address _strategy,\n    address _tokenIn,\n    address _tokenOut\n  ) external;\n}\n\nabstract contract TradeFactoryPositionsHandler is ITradeFactoryPositionsHandler, TradeFactorySwapperHandler {\n  using EnumerableSet for EnumerableSet.AddressSet;\n\n  bytes32 public constant STRATEGY = keccak256('STRATEGY');\n  bytes32 public constant STRATEGY_MANAGER = keccak256('STRATEGY_MANAGER');\n\n  EnumerableSet.AddressSet internal _strategies;\n\n  // strategy -> tokenIn[]\n  mapping(address => EnumerableSet.AddressSet) internal _tokensInByStrategy;\n\n  // strategy -> tokenIn -> tokenOut[]\n  mapping(address => mapping(address => EnumerableSet.AddressSet)) internal _tokensOutByStrategyAndTokenIn;\n\n  constructor(address _strategyModifier) {\n    if (_strategyModifier == address(0)) revert CommonErrors.ZeroAddress();\n    _setRoleAdmin(STRATEGY, STRATEGY_MANAGER);\n    _setRoleAdmin(STRATEGY_MANAGER, MASTER_ADMIN);\n    _setupRole(STRATEGY_MANAGER, _strategyModifier);\n  }\n\n  function enabledTrades() external view override returns (EnabledTrade[] memory _enabledTrades) {\n    uint256 _totalEnabledTrades;\n    for (uint256 i; i < _strategies.values().length; i++) {\n      address _strategy = _strategies.at(i);\n      address[] memory _tokensIn = _tokensInByStrategy[_strategy].values();\n      for (uint256 j; j < _tokensIn.length; j++) {\n        address _tokenIn = _tokensIn[j];\n        _totalEnabledTrades += _tokensOutByStrategyAndTokenIn[_strategy][_tokenIn].length();\n      }\n    }\n    _enabledTrades = new EnabledTrade[](_totalEnabledTrades);\n    uint256 _enabledTradesIndex;\n    for (uint256 i; i < _strategies.values().length; i++) {\n      address _strategy = _strategies.at(i);\n      address[] memory _tokensIn = _tokensInByStrategy[_strategy].values();\n      for (uint256 j; j < _tokensIn.length; j++) {\n        address _tokenIn = _tokensIn[j];\n        address[] memory _tokensOut = _tokensOutByStrategyAndTokenIn[_strategy][_tokenIn].values();\n        for (uint256 k; k < _tokensOut.length; k++) {\n          _enabledTrades[_enabledTradesIndex] = EnabledTrade(_strategy, _tokenIn, _tokensOut[k]);\n          _enabledTradesIndex++;\n        }\n      }\n    }\n  }\n\n  function enable(address _tokenIn, address _tokenOut) external override onlyRole(STRATEGY) {\n    if (_tokenIn == address(0) || _tokenOut == address(0)) revert CommonErrors.ZeroAddress();\n    _strategies.add(msg.sender);\n    _tokensInByStrategy[msg.sender].add(_tokenIn);\n    if (!_tokensOutByStrategyAndTokenIn[msg.sender][_tokenIn].add(_tokenOut)) revert InvalidTrade();\n  }\n\n  function disable(address _tokenIn, address _tokenOut) external override onlyRole(STRATEGY) {\n    _disable(msg.sender, _tokenIn, _tokenOut);\n  }\n\n  function disableByAdmin(\n    address _strategy,\n    address _tokenIn,\n    address _tokenOut\n  ) external override onlyRole(STRATEGY_MANAGER) {\n    // strategy.disableTradeCallback() -> tradeFactory.disable()\n    ISwapperEnabled(_strategy).disableTradeCallback(_tokenIn, _tokenOut);\n  }\n\n  function _disable(\n    address _strategy,\n    address _tokenIn,\n    address _tokenOut\n  ) internal {\n    if (_tokenIn == address(0) || _tokenOut == address(0)) revert CommonErrors.ZeroAddress();\n    if (IERC20(_tokenIn).allowance(msg.sender, address(this)) != 0) revert AllowanceShouldBeZero();\n    if (!_tokensOutByStrategyAndTokenIn[_strategy][_tokenIn].remove(_tokenOut)) revert InvalidTrade();\n    if (_tokensOutByStrategyAndTokenIn[_strategy][_tokenIn].length() == 0) {\n      _tokensInByStrategy[_strategy].remove(_tokenIn);\n      if (_tokensInByStrategy[_strategy].length() == 0) {\n        _strategies.remove(_strategy);\n      }\n    }\n  }\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.\n        return (a & b) + (a ^ b) / 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"
    },
    "@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"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/utils/Machinery.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\nimport '../interfaces/utils/IMachinery.sol';\nimport '../interfaces/mechanics/IMechanicsRegistry.sol';\n\nabstract contract 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\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"
    },
    "contracts/swappers/async/AsyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '../Swapper.sol';\n\ninterface IAsyncSwapper is ISwapper {\n  function swap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _minAmountOut,\n    bytes calldata _data\n  ) external;\n}\n\nabstract contract AsyncSwapper is IAsyncSwapper, Swapper {\n  // solhint-disable-next-line var-name-mixedcase\n  SwapperType public constant override SWAPPER_TYPE = SwapperType.ASYNC;\n\n  constructor(address _governor, address _tradeFactory) Governable(_governor) Swapper(_tradeFactory) {}\n\n  function _assertPreSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _minAmountOut\n  ) internal pure {\n    if (_receiver == address(0) || _tokenIn == address(0) || _tokenOut == address(0)) revert CommonErrors.ZeroAddress();\n    if (_amountIn == 0) revert CommonErrors.ZeroAmount();\n    if (_minAmountOut == 0) revert CommonErrors.ZeroAmount();\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal virtual;\n\n  function swap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    uint256 _minAmountOut,\n    bytes calldata _data\n  ) external virtual override onlyTradeFactory {\n    _assertPreSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _minAmountOut);\n    _executeSwap(_receiver, _tokenIn, _tokenOut, _amountIn, _data);\n  }\n}\n"
    },
    "contracts/swappers/async/MultipleAsyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport './AsyncSwapper.sol';\n\ninterface IMultipleAsyncSwapper is IAsyncSwapper {\n  function swapMultiple(bytes calldata _data) external;\n}\n\nabstract contract MultipleAsyncSwapper is IMultipleAsyncSwapper, AsyncSwapper {\n  constructor(address _governor, address _tradeFactory) AsyncSwapper(_governor, _tradeFactory) {}\n}\n"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/interfaces/utils/IMachinery.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\ninterface IMachinery {\n  // View helpers\n  function mechanicsRegistry() external view returns (address _mechanicsRegistry);\n\n  function isMechanic(address mechanic) external view returns (bool _isMechanic);\n\n  // Setters\n  function setMechanicsRegistry(address _mechanicsRegistry) external;\n}\n"
    },
    "@yearn-contracts/contract-utils/solidity/contracts/interfaces/mechanics/IMechanicsRegistry.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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"
    },
    "contracts/TradeFactory/TradeFactorySwapperHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/access/AccessControl.sol';\nimport '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';\n\nimport '../swappers/Swapper.sol';\n\nimport './TradeFactoryAccessManager.sol';\n\ninterface ITradeFactorySwapperHandler {\n  error NotAsyncSwapper();\n  error NotSyncSwapper();\n  error InvalidSwapper();\n  error SwapperInUse();\n\n  function strategySyncSwapper(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 _isSwapper);\n\n  function swapperStrategies(address _swapper) external view returns (address[] memory _strategies);\n\n  function setStrategySyncSwapper(address _strategy, address _swapper) external;\n\n  function addSwappers(address[] memory __swappers) 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 -> sync swapper\n  mapping(address => address) public override strategySyncSwapper;\n\n  constructor(address _swapperAdder, address _swapperSetter) {\n    if (_swapperAdder == address(0) || _swapperSetter == address(0)) revert CommonErrors.ZeroAddress();\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 _isSwapper) {\n    _isSwapper = _swappers.contains(_swapper);\n  }\n\n  function swappers() external view override returns (address[] memory _swappersList) {\n    _swappersList = _swappers.values();\n  }\n\n  function swapperStrategies(address _swapper) external view override returns (address[] memory _strategies) {\n    _strategies = _swapperStrategies[_swapper].values();\n  }\n\n  function setStrategySyncSwapper(address _strategy, address _swapper) external override onlyRole(SWAPPER_SETTER) {\n    if (_strategy == address(0) || _swapper == address(0)) revert CommonErrors.ZeroAddress();\n    // we check that swapper being added is async\n    if (ISwapper(_swapper).SWAPPER_TYPE() != ISwapper.SwapperType.SYNC) revert NotSyncSwapper();\n    // we check that swapper is not already added\n    if (!_swappers.contains(_swapper)) revert InvalidSwapper();\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  }\n\n  function addSwappers(address[] memory __swappers) external override onlyRole(SWAPPER_ADDER) {\n    for (uint256 i; i < __swappers.length; i++) {\n      if (__swappers[i] == address(0)) revert CommonErrors.ZeroAddress();\n      _swappers.add(__swappers[i]);\n    }\n  }\n\n  function removeSwappers(address[] memory __swappers) external override onlyRole(SWAPPER_ADDER) {\n    for (uint256 i; i < __swappers.length; i++) {\n      if (_swapperStrategies[__swappers[i]].length() > 0) revert SwapperInUse();\n      _swappers.remove(__swappers[i]);\n    }\n  }\n}\n"
    },
    "@openzeppelin/contracts/access/AccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\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 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]{40}) is missing role (0x[0-9a-f]{64})$/\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]{40}) is missing role (0x[0-9a-f]{64})$/\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        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, 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 <0.9.0;\n\nimport '@openzeppelin/contracts/access/AccessControl.sol';\n\nimport '../CommonErrors.sol';\n\nabstract contract TradeFactoryAccessManager is AccessControl {\n  bytes32 public constant MASTER_ADMIN = keccak256('MASTER_ADMIN');\n\n  constructor(address _masterAdmin) {\n    if (_masterAdmin == address(0)) revert CommonErrors.ZeroAddress();\n    _setRoleAdmin(MASTER_ADMIN, MASTER_ADMIN);\n    _setupRole(MASTER_ADMIN, _masterAdmin);\n  }\n}\n"
    },
    "@openzeppelin/contracts/access/IAccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\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 {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\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 {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\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) external;\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) external;\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) external;\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"
    },
    "@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"
    },
    "contracts/TradeFactory/TradeFactory.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@yearn-contracts/contract-utils/solidity/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  constructor(\n    address _masterAdmin,\n    address _swapperAdder,\n    address _swapperSetter,\n    address _strategyModifier,\n    address _mechanicsRegistry\n  )\n    TradeFactoryAccessManager(_masterAdmin)\n    TradeFactoryPositionsHandler(_strategyModifier)\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"
    },
    "contracts/swappers/async/MultiCallOptimizedSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport './MultipleAsyncSwapper.sol';\n\ninterface IMultiCallOptimizedSwapper is IMultipleAsyncSwapper {\n  error MultiCallRevert();\n  error CallOnlyOptimizationRequired();\n  enum MulticallOptimization {\n    None, // 0\n    CallOnly, // 1\n    SameTo, // 2\n    CallOnlySameTo, // 3\n    NoValue, // 4\n    CallOnlyNoValue, // 5\n    _6, // filler\n    CallOnlySameToNoValue // 7\n  }\n}\n\ncontract MultiCallOptimizedSwapper is IMultiCallOptimizedSwapper, MultipleAsyncSwapper {\n  using SafeERC20 for IERC20;\n\n  constructor(address _governor, address _tradeFactory) MultipleAsyncSwapper(_governor, _tradeFactory) {}\n\n  function _executeSwap(\n    address,\n    address,\n    address,\n    uint256,\n    bytes calldata _data\n  ) internal override {\n    uint8 multicallOptimization = _getMultiCallOptimization(_data);\n\n    bool _success;\n    if (multicallOptimization == uint8(MulticallOptimization.CallOnly)) {\n      _success = _multiSendCallOnly(_data); // OptimizedCall;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlySameTo)) {\n      _success = _multiSendCallOnlySameTo(_data); // OptimizedCallSameTo;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlyNoValue)) {\n      _success = _multiSendCallOnlyNoValue(_data); // OptimizedCallNoValue;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlySameToNoValue)) {\n      _success = _multiSendCallOnlySameToNoValue(_data); // OptimizedCallSameToNoValue;\n    } else {\n      revert CallOnlyOptimizationRequired();\n    }\n\n    if (!_success) revert MultiCallRevert();\n  }\n\n  function swapMultiple(bytes calldata _data) external override onlyTradeFactory {\n    uint8 multicallOptimization = _getMultiCallOptimization(_data);\n\n    bool _success;\n\n    if (multicallOptimization == uint8(MulticallOptimization.CallOnly)) {\n      _success = _multiSendCallOnly(_data); // OptimizedCall;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlySameTo)) {\n      _success = _multiSendCallOnlySameTo(_data); // OptimizedCallSameTo;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlyNoValue)) {\n      _success = _multiSendCallOnlyNoValue(_data); // OptimizedCallNoValue;\n    } else if (multicallOptimization == uint8(MulticallOptimization.CallOnlySameToNoValue)) {\n      _success = _multiSendCallOnlySameToNoValue(_data); // OptimizedCallSameToNoValue;\n    } else {\n      revert CallOnlyOptimizationRequired();\n    }\n\n    if (!_success) revert MultiCallRevert();\n  }\n\n  function _getMultiCallOptimization(bytes memory _data) internal pure returns (uint8 multicallOptimization) {\n    assembly {\n      multicallOptimization := shr(0xf8, shl(0x0, mload(add(_data, 0x20))))\n    }\n  }\n\n  function _multiSendCallOnly(bytes memory transactions) internal returns (bool _success) {\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      let length := mload(transactions)\n      // starts at + 32 bytes + 1 multicallOptimization byte\n      let i := 0x21\n      for {\n        // Pre block is not used in \"while mode\"\n      } lt(i, length) {\n        // Post block is not used in \"while mode\"\n      } {\n        // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n        let to := shr(0x60, mload(add(transactions, i)))\n        // We offset the load address by 20 byte (20 address bytes)\n        let value := mload(add(transactions, add(i, 0x14)))\n        // We offset the load address by 52 byte (20 address bytes + 32 value bytes)\n        let dataLength := mload(add(transactions, add(i, 0x34)))\n        // We offset the load address by 84 byte (20 address bytes + 32 value bytes + 32 data length bytes)\n        let data := add(transactions, add(i, 0x54))\n        _success := call(gas(), to, value, data, dataLength, 0, 0)\n        if eq(_success, 0) {\n          break\n        }\n\n        // Next entry starts at 84 byte + data length\n        i := add(i, add(0x54, dataLength))\n      }\n    }\n  }\n\n  function _multiSendCallOnlySameTo(bytes memory transactions) internal returns (bool _success) {\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      let length := mload(transactions)\n      // starts at + 32 bytes + 1 operation byte\n      let i := 0x21\n      // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n      let to := shr(0x60, mload(add(transactions, i)))\n      // We offset the load address by 20 byte (20 address bytes)\n      i := add(i, 0x14)\n      for {\n        // Pre block is not used in \"while mode\"\n      } lt(i, length) {\n        // Post block is not used in \"while mode\"\n      } {\n        let value := mload(add(transactions, add(i, 0x14)))\n        // We offset the load address by 52 byte (20 address bytes + 32 value bytes)\n        let dataLength := mload(add(transactions, add(i, 0x34)))\n        // We offset the load address by 84 byte (20 address bytes + 32 value bytes + 32 data length bytes)\n        let data := add(transactions, add(i, 0x54))\n        _success := call(gas(), to, value, data, dataLength, 0, 0)\n        if eq(_success, 0) {\n          break\n        }\n\n        // Next entry starts at 84 byte + data length\n        i := add(i, add(0x54, dataLength))\n      }\n    }\n  }\n\n  function _multiSendCallOnlyNoValue(bytes memory transactions) internal returns (bool _success) {\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      let length := mload(transactions)\n      // starts at + 32 bytes + 1 operation byte\n      let i := 0x21\n      for {\n        // Pre block is not used in \"while mode\"\n      } lt(i, length) {\n        // Post block is not used in \"while mode\"\n      } {\n        // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n        let to := shr(0x60, mload(add(transactions, i)))\n        // We offset the load address by 20 byte (20 address bytes)\n        let dataLength := mload(add(transactions, add(i, 0x14)))\n        // We offset the load address by 52 byte (20 address bytes + 32 data length bytes)\n        let data := add(transactions, add(i, 0x34))\n        _success := call(gas(), to, 0, data, dataLength, 0, 0)\n        if eq(_success, 0) {\n          break\n        }\n\n        // Next entry starts at 52 byte + data length\n        i := add(i, add(0x34, dataLength))\n      }\n    }\n  }\n\n  function _multiSendCallOnlySameToNoValue(bytes memory transactions) internal returns (bool _success) {\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      let length := mload(transactions)\n      // starts at + 32 bytes + 1 operation byte\n      let i := 0x21\n      // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.\n      let to := shr(0x60, mload(add(transactions, i)))\n      // We offset the load address by 20 byte (20 address bytes)\n      i := add(i, 0x14)\n      for {\n        // Pre block is not used in \"while mode\"\n      } lt(i, length) {\n        // Post block is not used in \"while mode\"\n      } {\n        let dataLength := mload(add(transactions, i))\n        // We offset the load address by 32 byte (32 data length bytes)\n        let data := add(transactions, add(i, 0x20))\n        _success := call(gas(), to, 0, data, dataLength, 0, 0)\n        if eq(_success, 0) {\n          break\n        }\n        // Next entry starts at 32 bytes + data length\n        i := add(i, add(0x20, dataLength))\n      }\n    }\n  }\n\n  // default msg.data handler\n  fallback() external payable {}\n\n  // direct payment no msg.data handler\n  receive() external payable {}\n}\n"
    },
    "contracts/swappers/async/ZRXSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport './AsyncSwapper.sol';\n\ninterface IZRXSwapper is IAsyncSwapper {\n  error TradeReverted();\n\n  // solhint-disable-next-line func-name-mixedcase\n  function ZRX() external view returns (address);\n}\n\ncontract ZRXSwapper is IZRXSwapper, AsyncSwapper {\n  using SafeERC20 for IERC20;\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  ) AsyncSwapper(_governor, _tradeFactory) {\n    ZRX = _ZRX;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal override {\n    uint256 _initialBalanceTokenIn = IERC20(_tokenIn).balanceOf(address(this));\n    IERC20(_tokenIn).approve(ZRX, 0);\n    IERC20(_tokenIn).approve(ZRX, _amountIn);\n    // solhint-disable-next-line avoid-low-level-calls\n    (bool success, ) = ZRX.call{value: 0}(_data);\n    if (!success) revert TradeReverted();\n    // Check that token in & amount in was correct (should be in AsyncSwapper)\n    if (_initialBalanceTokenIn - IERC20(_tokenIn).balanceOf(address(this)) < _amountIn) revert CommonErrors.IncorrectSwapInformation();\n    IERC20(_tokenOut).safeTransfer(_receiver, IERC20(_tokenOut).balanceOf(address(this)));\n  }\n}\n"
    },
    "contracts/swappers/async/UniswapV2Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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 './AsyncSwapper.sol';\n\ninterface IUniswapV2Swapper is IAsyncSwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function ROUTER() external view returns (address);\n}\n\ncontract UniswapV2Swapper is IUniswapV2Swapper, AsyncSwapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _uniswapFactory,\n    address _uniswapRouter\n  ) AsyncSwapper(_governor, _tradeFactory) {\n    FACTORY = _uniswapFactory;\n    ROUTER = _uniswapRouter;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal override {\n    address[] memory _path = abi.decode(_data, (address[]));\n    if (_tokenIn != _path[0] || _tokenOut != _path[_path.length - 1]) revert CommonErrors.IncorrectSwapInformation();\n    IERC20(_path[0]).approve(ROUTER, 0);\n    IERC20(_path[0]).approve(ROUTER, _amountIn);\n    IUniswapV2Router02(ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      0, // Slippage is checked after execution in trade factory\n      _path,\n      _receiver,\n      block.timestamp\n    );\n  }\n}\n"
    },
    "contracts/swappers/sync/UniswapV2AnchorSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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 './SyncSwapper.sol';\n\ninterface IUniswapV2AnchorSwapper is ISyncSwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function WANCHOR() 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 FACTORY() external view returns (address);\n\n  // solhint-disable-next-line func-name-mixedcase\n  function ROUTER() external view returns (address);\n}\n\ncontract UniswapV2AnchorSwapper is IUniswapV2AnchorSwapper, SyncSwapper {\n  using SafeERC20 for IERC20;\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 WANCHOR;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override FACTORY;\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    address _weth,\n    address _wanchor,\n    address _factory,\n    address _router\n  ) SyncSwapper(_governor, _tradeFactory) {\n    WETH = _weth;\n    WANCHOR = _wanchor;\n    FACTORY = _factory;\n    ROUTER = _router;\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 {\n    address[] memory _path;\n    uint256 _amountOut;\n    if (_data.length > 0) {\n      _path = abi.decode(_data, (address[]));\n      _amountOut = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _path)[_path.length - 1];\n    } else {\n      (_path, _amountOut) = _getPathAndAmountOut(_tokenIn, _tokenOut, _amountIn);\n    }\n    IERC20(_path[0]).approve(ROUTER, 0);\n    IERC20(_path[0]).approve(ROUTER, _amountIn);\n    IUniswapV2Router02(ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      _amountOut - ((_amountOut * _maxSlippage) / SLIPPAGE_PRECISION / 100), // slippage calcs\n      _path,\n      _receiver,\n      block.timestamp + 1800\n    );\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(FACTORY).getPair(_tokenIn, _tokenOut) != address(0)) {\n      _directPath = new address[](2);\n      _directPath[0] = _tokenIn;\n      _directPath[1] = _tokenOut;\n      _amountOutByDirectPath = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _directPath)[1];\n    }\n\n    uint256 _amountOutByWETHHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WETHHopPath;\n    if (IUniswapV2Factory(FACTORY).getPair(_tokenIn, WETH) != address(0) && IUniswapV2Factory(FACTORY).getPair(WETH, _tokenOut) != address(0)) {\n      _WETHHopPath = new address[](3);\n      _WETHHopPath[0] = _tokenIn;\n      _WETHHopPath[1] = WETH;\n      _WETHHopPath[2] = _tokenOut;\n      _amountOutByWETHHopPath = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _WETHHopPath)[2];\n    }\n\n    uint256 _amountOutByWANCHORHopPath;\n    // solhint-disable-next-line var-name-mixedcase\n    address[] memory _WANCHORHopPath;\n    if (\n      IUniswapV2Factory(FACTORY).getPair(_tokenIn, WANCHOR) != address(0) && IUniswapV2Factory(FACTORY).getPair(WANCHOR, _tokenOut) != address(0)\n    ) {\n      _WANCHORHopPath = new address[](3);\n      _WANCHORHopPath[0] = _tokenIn;\n      _WANCHORHopPath[1] = WANCHOR;\n      _WANCHORHopPath[2] = _tokenOut;\n      _amountOutByWANCHORHopPath = IUniswapV2Router02(ROUTER).getAmountsOut(_amountIn, _WANCHORHopPath)[2];\n    }\n\n    if (\n      Math.max(Math.max(_amountOutByDirectPath, _amountOutByWETHHopPath), Math.max(_amountOutByDirectPath, _amountOutByWANCHORHopPath)) ==\n      _amountOutByDirectPath\n    ) {\n      return (_directPath, _amountOutByDirectPath);\n    }\n\n    if (Math.max(_amountOutByWETHHopPath, _amountOutByWANCHORHopPath) == _amountOutByWETHHopPath) {\n      return (_WETHHopPath, _amountOutByWETHHopPath);\n    }\n\n    return (_WANCHORHopPath, _amountOutByWANCHORHopPath);\n  }\n}\n"
    },
    "contracts/swappers/async/SolidlySwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport './AsyncSwapper.sol';\nimport '../../interfaces/solidly/ISolidlyRouter.sol';\n\n\ninterface ISolidlySwapper is IAsyncSwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function ROUTER() external view returns (address);\n}\n\ncontract SolidlySwapper is ISolidlySwapper, AsyncSwapper {\n  using SafeERC20 for IERC20;\n\n  // solhint-disable-next-line var-name-mixedcase\n  address public immutable override ROUTER;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    // solhint-disable-next-line var-name-mixedcase\n    address _ROUTER\n  ) AsyncSwapper(_governor, _tradeFactory) {\n    ROUTER = _ROUTER;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal override {\n    ISolidlyRouter.route[] memory _path = abi.decode(_data, (ISolidlyRouter.route[]));\n    if (_tokenIn != _path[0].from || _tokenOut != _path[_path.length - 1].to) revert CommonErrors.IncorrectSwapInformation();\n    IERC20(_path[0].from).approve(ROUTER, 0);\n    IERC20(_path[0].from).approve(ROUTER, _amountIn);\n    ISolidlyRouter(ROUTER).swapExactTokensForTokens(\n      _amountIn,\n      0, // Slippage is checked after execution in trade factory\n      _path,\n      _receiver,\n      type(uint256).max\n    );\n  }\n}\n"
    },
    "contracts/interfaces/solidly/ISolidlyRouter.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\ninterface ISolidlyRouter {\n  struct route {\n    address from;\n    address to;\n    bool stable;\n  }\n\n  function factory() external view returns (address);\n\n  function pairFor(\n    address tokenA,\n    address tokenB,\n    bool stable\n  ) external view returns (address pair);\n\n  function getAmountsOut(uint256, route[] memory) external view returns (uint256[] memory amounts);\n\n  function swapExactTokensForTokensSimple(\n    uint256 amountIn,\n    uint256 amountOutMin,\n    address tokenFrom,\n    address tokenTo,\n    bool stable,\n    address to,\n    uint256 deadline\n  ) external returns (uint256[] memory);\n\n  function swapExactTokensForTokens(\n    uint256 amountIn,\n    uint256 amountOutMin,\n    route[] calldata routes,\n    address to,\n    uint256 deadline\n  ) external returns (uint256[] memory amounts);\n}\n"
    },
    "contracts/swappers/async/OneInchAggregatorSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport './AsyncSwapper.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 IAsyncSwapper {\n  // solhint-disable-next-line func-name-mixedcase\n  function AGGREGATION_ROUTER_V3() external view returns (address);\n}\n\ncontract OneInchAggregatorSwapper is IOneInchAggregatorSwapper, AsyncSwapper {\n  using SafeERC20 for IERC20;\n\n  uint256 private constant _SHOULD_CLAIM_FLAG = 0x04;\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  ) AsyncSwapper(_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    bytes calldata _data\n  ) internal override {\n    (IAggregationExecutor _caller, IOneInchExchange.SwapDescription memory _swapDescription, bytes memory _tradeData) = abi.decode(\n      _data[4:],\n      (IAggregationExecutor, IOneInchExchange.SwapDescription, bytes)\n    );\n    if (\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    ) revert CommonErrors.IncorrectSwapInformation();\n    IERC20(_tokenIn).approve(AGGREGATION_ROUTER_V3, 0);\n    IERC20(_tokenIn).approve(AGGREGATION_ROUTER_V3, _amountIn);\n    IOneInchExchange(AGGREGATION_ROUTER_V3).swap(_caller, _swapDescription, _tradeData);\n  }\n}\n"
    },
    "contracts/swappers/async/BancorSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport './AsyncSwapper.sol';\n\n\n\ninterface IContractRegistry {\n  function addressOf(bytes32 contractName) external returns (address);\n}\n\ninterface IBancorNetwork {\n  function convertByPath(\n    address[] memory _path,\n    uint256 _amount,\n    uint256 _minReturn,\n    address _beneficiary,\n    address _affiliateAccount,\n    uint256 _affiliateFee\n  ) external payable returns (uint256);\n\n  function rateByPath(address[] memory _path, uint256 _amount) external view returns (uint256);\n\n  function conversionPath(address _sourceToken, address _targetToken) external view returns (address[] memory);\n\n  function convert(\n    address[] memory path,\n    uint256 amount,\n    uint256 minReturn\n  ) external payable returns (uint256 returnAmount);\n}\n\ninterface IBancorSwapper is IAsyncSwapper {\n  function contractRegistry() external returns (IContractRegistry);\n\n  function bancorNetworkName() external returns (bytes32);\n}\n\ncontract BancorSwapper is IBancorSwapper, AsyncSwapper {\n  using SafeERC20 for IERC20;\n\n  IContractRegistry public immutable override contractRegistry;\n  bytes32 public immutable override bancorNetworkName;\n\n  constructor(\n    address _governor,\n    address _tradeFactory,\n    IContractRegistry _contractRegistry,\n    bytes32 _bancorNetworkName\n  ) AsyncSwapper(_governor, _tradeFactory) {\n    contractRegistry = _contractRegistry;\n    bancorNetworkName = _bancorNetworkName;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal override {\n    address[] memory _path = abi.decode(_data, (address[]));\n    if (_tokenIn != _path[0] || _tokenOut != _path[_path.length - 1]) revert CommonErrors.IncorrectSwapInformation();\n    IBancorNetwork _bancorNetwork = IBancorNetwork(contractRegistry.addressOf(bancorNetworkName));\n    IERC20(_tokenIn).approve(address(_bancorNetwork), 0);\n    IERC20(_tokenIn).approve(address(_bancorNetwork), _amountIn);\n    IERC20(_tokenOut).safeTransfer(_receiver, _bancorNetwork.convert(_path, _amountIn, 1));\n  }\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactorySwapperHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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(\n    address _masterAdmin, \n    address _swapperAdder, \n    address _swapperSetter\n  ) 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  function addSwapperToStrategyInternal(address _swapper, address _strategy) external {\n    _swapperStrategies[_swapper].add(_strategy);\n  }\n\n  function removeSwapperFromStrategyInternal(address _swapper, address _strategy) external {\n    _swapperStrategies[_swapper].remove(_strategy);\n  }\n\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactoryPositionsHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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 _strategyModifier\n  ) \n  TradeFactoryPositionsHandler(\n    _strategyModifier\n  ) \n  TradeFactorySwapperHandlerMock(\n    _masterAdmin, \n    _swapperAdder, \n    _swapperSetter\n  ) {}\n\n}\n"
    },
    "contracts/mock/TradeFactory/TradeFactoryExecutor.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\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 _strategyModifier, \n    address _mechanicsRegistry\n  ) \n    TradeFactoryPositionsHandlerMock(_masterAdmin, _swapperAdder, _swapperSetter, _strategyModifier)\n    TradeFactoryExecutor(_mechanicsRegistry) {}\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 Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(_msgSender(), recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        _approve(_msgSender(), spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * Requirements:\n     *\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``sender``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n\n        uint256 currentAllowance = _allowances[sender][_msgSender()];\n        require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n        unchecked {\n            _approve(sender, _msgSender(), currentAllowance - amount);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        uint256 currentAllowance = _allowances[_msgSender()][spender];\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `sender` to `recipient`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) internal virtual {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(sender, recipient, amount);\n\n        uint256 senderBalance = _balances[sender];\n        require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[sender] = senderBalance - amount;\n        }\n        _balances[recipient] += amount;\n\n        emit Transfer(sender, recipient, amount);\n\n        _afterTokenTransfer(sender, recipient, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n        }\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n}\n"
    },
    "contracts/mock/ERC20Mock.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.6;\n\nimport '@openzeppelin/contracts/token/ERC20/ERC20.sol';\n\ncontract ERC20Mock is ERC20 {\n  uint8 private _decimals;\n\n  constructor(\n    string memory _name,\n    string memory _symbol,\n    uint8 __decimals,\n    address _initialAccount,\n    uint256 _initialBalance\n  ) payable ERC20(_name, _symbol) {\n    _decimals = __decimals;\n    if (_initialBalance > 0) {\n      _mint(_initialAccount, _initialBalance);\n    }\n  }\n\n  function mint(address _account, uint256 _amount) external {\n    _mint(_account, _amount);\n  }\n\n  function burn(address _account, uint256 _amount) external {\n    _burn(_account, _amount);\n  }\n\n  function transferInternal(\n    address _from,\n    address _to,\n    uint256 _value\n  ) external {\n    _transfer(_from, _to, _value);\n  }\n\n  function approveInternal(\n    address _owner,\n    address _spender,\n    uint256 _value\n  ) external {\n    _approve(_owner, _spender, _value);\n  }\n\n  function decimals() public view virtual override returns (uint8) {\n    return _decimals;\n  }\n}"
    },
    "contracts/mock/swappers/Swapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '../../swappers/Swapper.sol';\n\ncontract SwapperMock is Swapper {\n\n  constructor(address _governor, address _tradeFactory) Swapper(_tradeFactory) Governable(_governor) {}\n\n  // solhint-disable-next-line func-name-mixedcase\n  function SWAPPER_TYPE() external view override returns (SwapperType) {\n    return SwapperType.ASYNC;\n  }\n\n  function modifierOnlyTradeFactory() external onlyTradeFactory { }\n}\n"
    },
    "contracts/mock/swappers/AsyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '../../swappers/async/AsyncSwapper.sol';\n\ncontract AsyncSwapperMock is AsyncSwapper {\n  uint256 internal _receivedAmount;\n\n  event MyInternalExecuteSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes _data\n  );\n\n  constructor(address _governor, address _tradeFactory) AsyncSwapper(_governor, _tradeFactory) {}\n\n  function setReceivedAmount(uint256 __receivedAmount) external {\n    _receivedAmount = __receivedAmount;\n  }\n\n  function _executeSwap(\n    address _receiver,\n    address _tokenIn,\n    address _tokenOut,\n    uint256 _amountIn,\n    bytes calldata _data\n  ) internal override virtual {\n    emit MyInternalExecuteSwap(\n      _receiver,\n      _tokenIn,\n      _tokenOut,\n      _amountIn,\n      _data\n    );\n  }\n}\n"
    },
    "contracts/mock/swappers/SyncSwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4 <0.9.0;\n\nimport '../../swappers/sync/SyncSwapper.sol';\n\ncontract SyncSwapperMock is SyncSwapper {\n\n  constructor(address _governor, address _tradeFactory) SyncSwapper(_governor, _tradeFactory) {}\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 virtual { }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "storageLayout",
          "evm.gasEstimates"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {
      "": {
        "__CACHE_BREAKER__": "0x00000000d41867734bbee4c6863d9255b2b06ac1"
      }
    }
  }
}