diff --git a/src/oracles/reserve/pendle/EzEthPtReserveOracle.sol b/src/oracles/reserve/pendle/EzEthPtReserveOracle.sol index ca3b1ca4..f29d3dd4 100644 --- a/src/oracles/reserve/pendle/EzEthPtReserveOracle.sol +++ b/src/oracles/reserve/pendle/EzEthPtReserveOracle.sol @@ -31,6 +31,6 @@ contract EzEthPtReserveOracle is ReserveOracle { (,, uint256 totalTVL) = RENZO_RESTAKE_MANAGER.calculateTVLs(); uint256 totalSupply = EZETH.totalSupply(); - return totalTVL.mulDiv(1e18, totalSupply); + return totalSupply.mulDiv(1e18, totalTVL); } } diff --git a/src/oracles/reserve/pendle/RsEthPtReserveOracle.sol b/src/oracles/reserve/pendle/RsEthPtReserveOracle.sol index 711e97da..cc4002b5 100644 --- a/src/oracles/reserve/pendle/RsEthPtReserveOracle.sol +++ b/src/oracles/reserve/pendle/RsEthPtReserveOracle.sol @@ -1,15 +1,20 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.21; +import { WAD } from "../../../libraries/math/WadRayMath.sol"; import { RSETH_LRT_ORACLE } from "../../../Constants.sol"; import { ReserveOracle } from "../ReserveOracle.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; + /** * @notice Reserve Oracle for PT-rsETH * * @custom:security-contact security@molecularlabs.io */ contract RsEthPtReserveOracle is ReserveOracle { + using Math for uint256; + constructor( uint8 _ilkIndex, address[] memory _feeds, @@ -24,6 +29,6 @@ contract RsEthPtReserveOracle is ReserveOracle { * at maturity, we need to convert 1 ETH of value into rsETH terms. */ function _getProtocolExchangeRate() internal view override returns (uint256) { - return RSETH_LRT_ORACLE.rsETHPrice(); + return WAD.mulDiv(WAD, RSETH_LRT_ORACLE.rsETHPrice()); } } diff --git a/test/fork/concrete/pendle/PtReserveOracle.t.sol b/test/fork/concrete/pendle/PtReserveOracle.t.sol new file mode 100644 index 00000000..73df9f86 --- /dev/null +++ b/test/fork/concrete/pendle/PtReserveOracle.t.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.21; + +import { Test } from "forge-std/Test.sol"; +import { EzEthPtReserveOracle } from "../../../../src/oracles/reserve/pendle/EzEthPtReserveOracle.sol"; +import { RsEthPtReserveOracle } from "../../../../src/oracles/reserve/pendle/RsEthPtReserveOracle.sol"; +import { RswEthPtReserveOracle } from "../../../../src/oracles/reserve/pendle/RswEthPtReserveOracle.sol"; +import { WeEthPtReserveOracle } from "../../../../src/oracles/reserve/pendle/WeEthPtReserveOracle.sol"; + +contract PtReserveOracleTest is Test { + function setUp() public { + vm.createSelectFork(vm.envString("MAINNET_RPC_URL")); + } + + function test_WeEth() public { + WeEthPtReserveOracle reserveOracle = new WeEthPtReserveOracle(0, new address[](3), 0, 0.02e18); + assertLe(reserveOracle.getProtocolExchangeRate(), 1e18); + } + + function test_RsEth() public { + RsEthPtReserveOracle reserveOracle = new RsEthPtReserveOracle(0, new address[](3), 0, 0.02e18); + assertLe(reserveOracle.getProtocolExchangeRate(), 1e18); + } + + function test_RswEth() public { + RswEthPtReserveOracle reserveOracle = new RswEthPtReserveOracle(0, new address[](3), 0, 0.02e18); + assertLe(reserveOracle.getProtocolExchangeRate(), 1e18); + } + + function test_EzEth() public { + EzEthPtReserveOracle reserveOracle = new EzEthPtReserveOracle(0, new address[](3), 0, 0.02e18); + assertLe(reserveOracle.getProtocolExchangeRate(), 1e18); + } +}