creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/SpotOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.10;\n\nimport \"./interfaces/AggregatorV3Interface.sol\";\n\ncontract SpotOracle {\n    mapping(uint256 => uint256) public settlePrices;\n    AggregatorV3Interface immutable internal PRICEFEED;\n    uint256 public latestExpiryUpdated = 0;\n\n    event Settled(uint256 expiry, uint256 settlePrice);\n\n    constructor(\n        AggregatorV3Interface priceFeed\n    ) {\n        PRICEFEED = priceFeed;\n    }\n\n    // settle price\n    function settle() public {\n        uint256 expiry = block.timestamp - block.timestamp % 86400 + 28800;\n        require(block.timestamp >= expiry, \"Oracle: not expired\");\n        require(settlePrices[expiry] == 0, \"Oracle: already settled\");\n\n        uint256 currentPrice = uint256(getLatestPrice());\n        if (latestExpiryUpdated != 0 && latestExpiryUpdated <= expiry - 86400 * 2) {\n            uint256 missedDays = (expiry - latestExpiryUpdated) / 86400;\n            uint256 startPrice = settlePrices[latestExpiryUpdated];\n\n            for (uint256 i = 1; i < missedDays; i++) {\n                uint256 missedExpiry = latestExpiryUpdated + i * 86400;\n                uint256 missedDayPrice;\n                if (startPrice > currentPrice) {\n                    missedDayPrice = startPrice - (startPrice - currentPrice) * i / missedDays;\n                } else {\n                    missedDayPrice = startPrice + (currentPrice - startPrice) * i / missedDays;\n                }\n                settlePrices[missedExpiry] = missedDayPrice;\n                emit Settled(missedExpiry, missedDayPrice);\n            }\n        }\n\n        settlePrices[expiry] = currentPrice;\n        latestExpiryUpdated = expiry;\n\n        emit Settled(expiry, currentPrice);\n    }\n\n    function getLatestPrice() internal view returns (int) {\n        // prettier-ignore\n        (\n        /* uint80 roundID */,\n        int price,\n        /*uint startedAt*/,\n        /*uint timeStamp*/,\n        /*uint80 answeredInRound*/\n        ) = PRICEFEED.latestRoundData();\n        require(price > 0, \"Oracle: invalid price\");\n\n        return price;\n    }\n}"
      },
      "src/interfaces/AggregatorV3Interface.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\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(\n        uint80 _roundId\n    ) external view 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}"
      }
    },
    "settings": {
      "remappings": [
        "@chainlink/contracts/=lib/foundry-chainlink-toolkit/lib/chainlink-brownie-contracts/contracts/src/",
        "@openzeppelin/=lib/foundry-chainlink-toolkit/lib/openzeppelin-contracts/",
        "chainlink-brownie-contracts/=lib/foundry-chainlink-toolkit/lib/chainlink-brownie-contracts/contracts/src/v0.6/vendor/@arbitrum/nitro-contracts/src/",
        "ds-test/=lib/foundry-chainlink-toolkit/lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "foundry-chainlink-toolkit/=lib/foundry-chainlink-toolkit/",
        "openzeppelin-contracts/=lib/foundry-chainlink-toolkit/lib/openzeppelin-contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": false,
      "libraries": {}
    }
  }}