creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\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    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) 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 a `value` amount of tokens as the allowance of `spender` over the\n     * 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 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "contracts/interfaces/IStaticATokenLM.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.23;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n// STATA_TOKENS in AaveV3\ninterface IStaticATokenLM {\n    function aToken() external view returns (IERC20);\n    function rate() external view returns (uint256);\n}\n\ninterface IStaticATokenFactory {\n    function getStaticAToken(address underlying) external view returns (address);\n    function getStaticATokens() external view returns (address[] memory);\n}\n"
      },
      "contracts/interfaces/IWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.23;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWrapper {\n    error NotSupportedToken();\n    error NotAddedMarket();\n    error NotRemovedMarket();\n\n    function wrap(IERC20 token) external view returns (IERC20 wrappedToken, uint256 rate);\n}\n"
      },
      "contracts/wrappers/StataTokenWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.23;\n\nimport \"../interfaces/IStaticATokenLM.sol\";\nimport \"../interfaces/IWrapper.sol\";\n\ncontract StataTokenWrapper is IWrapper {\n    IStaticATokenFactory public immutable FACTORY;\n\n    mapping(IERC20 => IERC20) public stataTokenToToken;\n    mapping(IERC20 => IERC20) public tokenToStataToken;\n\n    constructor(IStaticATokenFactory staticATokenFactory) {\n        FACTORY = staticATokenFactory;\n    }\n\n    function addMarkets(IERC20[] memory tokens) external {\n        unchecked {\n            for (uint256 i = 0; i < tokens.length; i++) {\n                IERC20 stataToken = IERC20(FACTORY.getStaticAToken(address(tokens[i])));\n                if(stataToken == IERC20(address(0))) revert NotAddedMarket();\n                stataTokenToToken[stataToken] = tokens[i];\n                tokenToStataToken[tokens[i]] = stataToken;\n            }\n        }\n    }\n\n    function removeMarkets(IERC20[] memory tokens) external {\n        unchecked {\n            for (uint256 i = 0; i < tokens.length; i++) {\n                IERC20 stataToken = IERC20(FACTORY.getStaticAToken(address(tokens[i])));\n                if(stataToken == IERC20(address(0))) revert NotRemovedMarket();\n                delete stataTokenToToken[stataToken];\n                delete tokenToStataToken[tokens[i]];\n            }\n        }\n    }\n\n    function wrap(IERC20 token) external view override returns (IERC20 wrappedToken, uint256 rate) {\n        IERC20 underlying = stataTokenToToken[token];\n        IERC20 stataToken = tokenToStataToken[token];\n        if (underlying != IERC20(address(0))) {\n            return (underlying, IStaticATokenLM(address(token)).rate() / 1e9);\n        } else if (stataToken != IERC20(address(0))) {\n            return (stataToken, 1e45 / IStaticATokenLM(address(stataToken)).rate());\n        } else {\n            revert NotSupportedToken();\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 1000000
      },
      "evmVersion": "shanghai",
      "viaIR": true,
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}