Skip to content

Commit

Permalink
fix: Three Sigma audit fixes (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari authored Dec 6, 2024
1 parent af79d0b commit 00b1548
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/OjoPTOraclePriceAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,38 @@ contract OjoPTOraclePriceAdapter is MinimalAggregatorV3Interface {

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 OjoPTOraclePriceAdapter__MarketNotInitialized = 10_001;

error OjoPTOraclePriceAdapterError(uint256 errorId_);

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;
if (MinimalAggregatorV3Interface(_market).decimals() != decimals) {
revert OjoPTOraclePriceAdapterError(OjoPTOraclePriceAdapter__MarketDecimalsNotSupported);
}

IPTOracle oracle = IPTOracle(PTOracle);

{
(bool increaseCardinalityRequired_,, bool oldestObservationSatisfied_) = oracle.getOracleState(
market,
900 // 15 mins twap duration
);
if (increaseCardinalityRequired_ || !oldestObservationSatisfied_) {
// ensure pendle market Oracle is ready and initialized see
// https://docs.pendle.finance/Developers/Oracles/HowToIntegratePtAndLpOracle
revert OjoPTOraclePriceAdapterError(OjoPTOraclePriceAdapter__MarketNotInitialized);
}
}
}

/// @inheritdoc MinimalAggregatorV3Interface
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/IPTOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ pragma solidity >=0.5.0;

interface IPTOracle {
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);

function getOracleState(
address market,
uint32 duration
)
external
view
returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied);
}

0 comments on commit 00b1548

Please sign in to comment.