creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/ports/oracles/ChainlinkOracle.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.21;\n\nimport { AggregatorV3Interface } from \"src/interfaces/AggregatorV3Interface.sol\";\nimport { IOracle } from \"src/interfaces/IOracle.sol\";\nimport { ErrorsLeverageEngine } from \"src/libs/ErrorsLeverageEngine.sol\";\n\ncontract ChainlinkOracle is IOracle {\n    AggregatorV3Interface internal chainlinkOracleInstance;\n    uint256 public priceStaleThreshold;\n\n    constructor(address _oracle, uint256 _priceStaleThreshold) {\n        chainlinkOracleInstance = AggregatorV3Interface(_oracle);\n        priceStaleThreshold = _priceStaleThreshold;\n    }\n\n    function decimals() external view returns (uint8) {\n        return chainlinkOracleInstance.decimals();\n    }\n\n    function getLatestPrice() external view returns (uint256) {\n        (, int256 price,, uint256 updatedAt,) = chainlinkOracleInstance.latestRoundData();\n\n        if (updatedAt + priceStaleThreshold < block.timestamp) revert ErrorsLeverageEngine.OraclePriceStale();\n        if (price <= 0) revert ErrorsLeverageEngine.OracleNegativePrice();\n        return uint256(price);\n    }\n}\n"
      },
      "src/interfaces/AggregatorV3Interface.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.21;\n\ninterface AggregatorV3Interface {\n    function decimals() external view returns (uint8);\n\n    function description() external view returns (string memory);\n\n    function version() external view returns (uint256);\n\n    function getRoundData(uint80 _roundId)\n        external\n        view\n        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\n\n    function latestRoundData()\n        external\n        view\n        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\n}\n"
      },
      "src/interfaces/IOracle.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.21;\n\ninterface IOracle {\n    \n    function decimals() external view returns (uint8);\n\n    function getLatestPrice() external view returns (uint256);\n}\n"
      },
      "src/libs/ErrorsLeverageEngine.sol": {
        "content": "// SPDX-License-Identifier: CC BY-NC-ND 4.0\npragma solidity >=0.8.21;\n\nlibrary ErrorsLeverageEngine {\n    error ExceedBorrowLimit(); // 8b085be2\n    error LessThanMinimumShares(); // 3beecf45\n    error OracleNotSet(); // f8794e04\n    error OraclePriceStale(); // 08b9f95b\n    error OracleNegativePrice(); // 641f4716\n    error NotEnoughTokensReceived(); // 828f02ae\n    error OraclePriceError(); // fa80e24f\n    error ExceedBorrowQuota(); // d7f5242d\n    error NotOwner(); // 30cd7471\n    error PositionNotLive(); // 5117a49b\n    error PositionNotExpiredOrLiquidated(); // 382dc85b\n    error NotEnoughWBTC(); // 8445ce78\n    error NotEligibleForLiquidation(); // 5e6797f9\n    error InsufficientFunds(); // 356680b7\n    error PositionHasNoBalance(); // 1414023b\n    error SwapAdapterAlreadySet(); // b33e2407\n    error PositionMustLiveForMinDuration(); // 7616ad40\n    error NotEligibleForExpiration(); //6db32f8f\n    error AmountMustBeGreaterThanZero(); //5e85ae73\n    error BlockCountTooLow(); //0d14f234\n    error BlockCountTooHigh(); //4de7b564\n    error SwapAdapterNotSet(); //afd1c360\n    error PositionLifetimeTooShort(); //4ebfd554\n    error PositionAlreadyExists(); //6e8de458\n    error PositionDoesNotExist(); //f7b3b391\n    error FeeTooHigh(); //cd4e6167\n    error NotEnoughLvBTC();\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@prb/test/=lib/prb-test/src/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
        "ERC721A/=lib/ERC721A/contracts/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@contracts/=src/",
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
        "prb-test/=lib/prb-test/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 10000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "shanghai",
      "viaIR": false,
      "libraries": {}
    }
  }}