Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ: C-01 #77

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/oracles/reserve/pendle/EzEthPtReserveOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 6 additions & 1 deletion src/oracles/reserve/pendle/RsEthPtReserveOracle.sol
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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());
}
}
34 changes: 34 additions & 0 deletions test/fork/concrete/pendle/PtReserveOracle.t.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading