-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from Ion-Protocol/hrikb/C-01
OZ: C-01
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
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
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 [email protected] | ||
*/ | ||
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()); | ||
} | ||
} |
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,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); | ||
} | ||
} |