creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@swaap-labs/v2-errors/contracts/SwaapV2Errors.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.7.0 <0.9.0;\n\nlibrary SwaapV2Errors {\n    // Safeguard Pool\n    uint256 internal constant EXCEEDED_SWAP_AMOUNT_IN = 0;\n    uint256 internal constant EXCEEDED_SWAP_AMOUNT_OUT = 1;\n    uint256 internal constant UNFAIR_PRICE = 2;\n    uint256 internal constant LOW_PERFORMANCE = 3;\n    uint256 internal constant MIN_BALANCE_OUT_NOT_MET = 4;\n    uint256 internal constant NOT_ENOUGH_PT_OUT = 5;\n    uint256 internal constant EXCEEDED_BURNED_PT = 6;\n    uint256 internal constant SIGNER_CANNOT_BE_NULL_ADDRESS = 7;\n    uint256 internal constant PERFORMANCE_UPDATE_INTERVAL_TOO_LOW = 8;\n    uint256 internal constant PERFORMANCE_UPDATE_INTERVAL_TOO_HIGH = 9;\n    uint256 internal constant MAX_PERFORMANCE_DEV_TOO_LOW = 10;\n    uint256 internal constant MAX_PERFORMANCE_DEV_TOO_HIGH = 11;\n    uint256 internal constant MAX_TARGET_DEV_TOO_LOW = 12;\n    uint256 internal constant MAX_TARGET_DEV_TOO_LARGE = 13;\n    uint256 internal constant MAX_PRICE_DEV_TOO_LOW = 14;\n    uint256 internal constant MAX_PRICE_DEV_TOO_LARGE = 15;\n    uint256 internal constant PERFORMANCE_UPDATE_TOO_SOON = 16;\n    uint256 internal constant BITMAP_SIGNATURE_NOT_VALID = 17;\n    uint256 internal constant QUOTE_ALREADY_USED = 18;\n    uint256 internal constant REPLAYABLE_SIGNATURE_NOT_VALID = 19;\n    uint256 internal constant QUOTE_BALANCE_NO_LONGER_VALID = 20;\n    uint256 internal constant WRONG_TOKEN_IN_IN_EXCESS = 21;\n    uint256 internal constant WRONG_TOKEN_OUT_IN_EXCESS = 22;\n    uint256 internal constant EXCEEDS_TIMEOUT = 23;\n    uint256 internal constant NON_POSITIVE_PRICE = 24;\n    uint256 internal constant FEES_TOO_HIGH = 25;\n    uint256 internal constant LOW_INITIAL_BALANCE = 26;\n    uint256 internal constant ORACLE_TIMEOUT_TOO_HIGH = 27;\n    uint256 internal constant OUTDATED_ORACLE_ROUND_ID = 28;\n    uint256 internal constant LOW_SWAP_AMOUNT_IN = 29;\n    uint256 internal constant LOW_SWAP_AMOUNT_OUT = 30;\n    uint256 internal constant PAUSED = 31;\n    uint256 internal constant INVALID_AGGREGATOR = 32;\n    uint256 internal constant PASSED_DEADLINE = 33;\n    uint256 internal constant SAME_TOKENS = 34;\n    uint256 internal constant INVALID_DATA_LENGTH = 35;\n}\n\n/**\n* @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 99 are\n* supported.\n*/\nfunction _srequire(bool condition, uint256 errorCode) pure {\n    if (!condition) _srevert(errorCode);\n}\n\n\n/**\n * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 99 are supported.\n */\nfunction _srevert(uint256 errorCode) pure {\n    // We're going to dynamically create a revert uint256 based on the error code, with the following format:\n    // 'SWAAP#{errorCode}'\n    // where the code is left-padded with zeroes to two digits (so they range from 00 to 99).\n    //\n    // We don't have revert uint256s embedded in the contract to save bytecode size: it takes much less space to store a\n    // number (8 to 16 bits) than the individual uint256 characters.\n    //\n    // The dynamic uint256 creation algorithm that follows could be implemented in Solidity, but assembly allows for a\n    // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a\n    // safe place to rely on it without worrying about how its usage might affect e.g. memory contents.\n    assembly {\n        // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-99\n        // range, so we only need to convert two digits. To convert the digits to ASCII, we add 0x30, the value for\n        // the '0' character.\n\n        let units := add(mod(errorCode, 10), 0x30)\n\n        errorCode := div(errorCode, 10)\n        let tenths := add(mod(errorCode, 10), 0x30)\n\n        // With the individual characters, we can now construct the full uint256. The SWAAP# part is a known constant\n        // (0x535741415023): we simply shift this by 16 (to provide space for the 2 bytes of the error code), and add\n        // the characters to it, each shifted by a multiple of 8.\n        // The revert reason is then shifted left by 192 bits (256 minus the length of the uint256, 8 characters * 8\n        // bits per character = 64) to locate it in the most significant part of the 256 slot (the beginning of a byte\n        // array).\n\n        let revertReason := shl(192, add(0x5357414150230000, add(units, shl(8, tenths))))\n\n        // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded\n        // message will have the following layout:\n        // [ revert reason identifier ] [ uint256 location offset ] [ uint256 length ] [ uint256 contents ]\n\n        // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(uint256) function. We\n        // also write zeroes to the next 29 bytes of memory, but those are about to be overwritten.\n        mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n        // Next is the offset to the location of the uint256, which will be placed immediately after (20 bytes away).\n        mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\n        // The uint256 length is fixed: 8 characters.\n        mstore(0x24, 8)\n        // Finally, the uint256 itself is stored.\n        mstore(0x44, revertReason)\n\n        // Even if the uint256 is only 8 bytes long, we need to return a full 32 byte slot containing it. The length of\n        // the encoded message is therefore 4 + 32 + 32 + 32 = 100.\n        revert(0, 100)\n    }\n}\n"
      },
      "@swaap-labs/v2-interfaces/contracts/standalone-utils/IStETH.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.7.0 <0.9.0;\n\ninterface IStETH {\n  function getPooledEthByShares(uint256 shares) external view returns (uint256);\n}\n"
      },
      "@swaap-labs/v2-interfaces/contracts/standalone-utils/IWstETHToETHPriceAdapter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.7.0 <0.9.0;\n\ninterface IWstETHToETHPriceAdapter {\n\n  /**\n   * @notice Calculates the current answer based on the aggregators.\n   */\n  function latestRoundData()\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  /**\n   * @notice Returns the description of the feed\n   * @return string desciption\n   */\n  function description() external view returns (string memory);\n\n  /**\n   * @notice Returns the feed decimals\n   * @return uint8 decimals\n   */\n  function decimals() external view returns (uint8);\n\n}"
      },
      "contracts/WstETHToETH.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n/*\n                                      s███\n                                    ██████\n                                   @██████\n                              ,s███`\n                           ,██████████████\n                          █████████^@█████_\n                         ██████████_ 7@███_            \"█████████M\n                        @██████████_     `_              \"@█████b\n                        ^^^^^^^^^^\"                         ^\"`\n                         \n                        ████████████████████p   _█████████████████████\n                        @████████████████████   @███████████WT@██████b\n                         ████████████████████   @███████████  ,██████\n                         @███████████████████   @███████████████████b\n                          @██████████████████   @██████████████████b\n                           \"█████████████████   @█████████████████b\n                             @███████████████   @████████████████\n                               %█████████████   @██████████████`\n                                 ^%██████████   @███████████\"\n                                     ████████   @██████W\"`\n                                     1███████\n                                      \"@█████\n                                         7W@█\n*/\n\npragma solidity ^0.8.18;\n\nimport \"@swaap-labs/v2-interfaces/contracts/standalone-utils/IStETH.sol\";\nimport \"@swaap-labs/v2-interfaces/contracts/standalone-utils/IWstETHToETHPriceAdapter.sol\";\nimport \"@swaap-labs/v2-errors/contracts/SwaapV2Errors.sol\";\n\n/**\n * @title WstETHToBasePriceAdapter\n * @author Swaap-labs (https://github.com/swaap-labs/swaap-v2-monorepo)\n * @notice Price adapter to calculate price of (wstETH / USD) pair by using\n * @notice Chainlink data feed for (stETH / USD) and (wstETH / stETH) ratio.\n * @dev This contract is used to calculate price of (wstETH / USD) pair. The contract is\n * @dev inspired by WstETHSynchronicityPriceAdapter developed by BGD Labs & used by Aave.\n*/\n\ncontract WstETHToETHPriceAdapter is IWstETHToETHPriceAdapter {\n\n  /**\n   * @notice stETH token contract to get ratio\n   */\n  IStETH public constant STETH = IStETH(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84); // stETH on mainnet\n\n  /**\n   * @notice Number of decimals in the output of this price adapter\n   */\n\n  uint8 private constant _PRICE_DECIMALS = 18;\n\n  uint256 private constant _ONE = 10**uint256(_PRICE_DECIMALS);\n\n  /// @inheritdoc IWstETHToETHPriceAdapter\n  function description() external view override returns (string memory) {\n    return \"wstETH / ETH\";\n  }\n\n  /// @inheritdoc IWstETHToETHPriceAdapter\n  function decimals() external pure override returns (uint8) {\n    return _PRICE_DECIMALS;\n  }\n\n  /// @inheritdoc IWstETHToETHPriceAdapter\n  function latestRoundData() external view override\n  returns (uint80, int256, uint256, uint256, uint80) {\n\n    int256 rate = int256(STETH.getPooledEthByShares(_ONE));\n\n    _srequire(rate > 0, SwaapV2Errors.NON_POSITIVE_PRICE);\n\n    return (\n      1,\n      rate,\n      block.timestamp,\n      block.timestamp,\n      1\n    );\n  }\n\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 99999
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}