-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26a475c
commit 7a31d2e
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.8.19; | ||
|
||
import {IPTOracle} from "./interfaces/IPTOracle.sol"; | ||
import {MinimalAggregatorV3Interface} from "./interfaces/MinimalAggregatorV3Interface.sol"; | ||
|
||
contract OjoPTOraclePriceAdapter is MinimalAggregatorV3Interface { | ||
uint8 public constant decimals = 18; | ||
|
||
address public immutable PTOracle; | ||
|
||
address public immutable market; | ||
|
||
string public description; | ||
|
||
constructor(address _ptoracle, address _market, string memory _description) { | ||
require(_ptoracle != address(0), "_ptoracle zero address"); | ||
require(_market != address(0), "_market zero address"); | ||
|
||
PTOracle = _ptoracle; | ||
market = _market; | ||
description = _description; | ||
} | ||
|
||
/// @inheritdoc MinimalAggregatorV3Interface | ||
/// @dev Returns zero for roundId, startedAt, updatedAt and answeredInRound. | ||
/// @dev Silently overflows if `price`'s average is greater than `type(int256).max`. | ||
function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) { | ||
IPTOracle oracle = IPTOracle(PTOracle); | ||
|
||
uint256 price = oracle.getPtToAssetRate( | ||
market, | ||
900 // 15 mins twap duration | ||
); | ||
|
||
return (0, int256(price), 0, 0, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.5.0; | ||
|
||
interface IPTOracle { | ||
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.5.0; | ||
|
||
/// @dev Inspired by | ||
/// https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol | ||
/// @dev This is the minimal feed interface required by `MorphoChainlinkOracleV2`. | ||
interface MinimalAggregatorV3Interface { | ||
/// @notice Returns the precision of the feed. | ||
function decimals() external view returns (uint8); | ||
|
||
/// @notice Returns Chainlink's `latestRoundData` return values. | ||
/// @notice Only the `answer` field is used by `MorphoChainlinkOracleV2`. | ||
function latestRoundData() | ||
external | ||
view | ||
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); | ||
} |