Skip to content

Commit

Permalink
decimal check
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Dec 6, 2024
1 parent b216be3 commit e64e52a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/OjoPTOraclePriceAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import {IPTOracle} from "./interfaces/IPTOracle.sol";
import {MinimalAggregatorV3Interface} from "./interfaces/MinimalAggregatorV3Interface.sol";

contract OjoPTOraclePriceAdapter is MinimalAggregatorV3Interface {
uint8 public decimals;
uint8 public constant decimals = 18;

address public immutable PTOracle;

address public immutable market;

string public description;

/// @notice thrown when the Pendle market decimals are not 18
uint256 internal constant OjoPTOraclePriceAdapter__MarketDecimalsNotSupported = 10_000;

/// @notice thrown when the Pendle market Oracle has not been initialized yet
uint256 internal constant PendleOracle__MarketNotInitialized = 10_000;
uint256 internal constant OjoPTOraclePriceAdapter__MarketNotInitialized = 10_001;

error OjoPTOraclePriceAdapterError(uint256 errorId_);

Expand All @@ -25,7 +28,9 @@ contract OjoPTOraclePriceAdapter is MinimalAggregatorV3Interface {
PTOracle = _ptoracle;
market = _market;
description = _description;
decimals = MinimalAggregatorV3Interface(_market).decimals();
if (MinimalAggregatorV3Interface(_market).decimals() != decimals) {
revert OjoPTOraclePriceAdapterError(OjoPTOraclePriceAdapter__MarketDecimalsNotSupported);
}

IPTOracle oracle = IPTOracle(PTOracle);

Expand All @@ -37,7 +42,7 @@ contract OjoPTOraclePriceAdapter is MinimalAggregatorV3Interface {
if (increaseCardinalityRequired_ || !oldestObservationSatisfied_) {
// ensure pendle market Oracle is ready and initialized see
// https://docs.pendle.finance/Developers/Oracles/HowToIntegratePtAndLpOracle
revert OjoPTOraclePriceAdapterError(PendleOracle__MarketNotInitialized);
revert OjoPTOraclePriceAdapterError(OjoPTOraclePriceAdapter__MarketNotInitialized);
}
}
}
Expand Down

0 comments on commit e64e52a

Please sign in to comment.