-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: deploy-oracle-PT-Dec-maturity #257
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1e4a85a
feat: deploy-oracle-PT-Dec-maturity
GuillaumeNervoXS dc3adfa
add ezETH market
GuillaumeNervoXS 85736df
fix tests
GuillaumeNervoXS 6bd497d
fix tests
GuillaumeNervoXS 736652b
deployed Pendle PT LRT oracles
GuillaumeNervoXS 6bfdc08
fix tests
GuillaumeNervoXS 6293e8a
fix Pendle oracles
GuillaumeNervoXS eb248ca
ezETH feed Morpho compatible
GuillaumeNervoXS 2a11d11
feat: fix PT oracles
GuillaumeNervoXS a6c4dfe
deploy new oracles for PTezETH and PTweETH
GuillaumeNervoXS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
contracts/oracle/morpho/mainnet/MorphoFeedPTweETHDec24.sol
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,40 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.12; | ||
|
||
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | ||
|
||
import "../../BaseFeedPTPendle.sol"; | ||
|
||
/// @title MorphoFeedPTweETH | ||
/// @author Angle Labs, Inc. | ||
/// @notice Gives the price of PT-weETH in ETH in base 18 | ||
contract MorphoFeedPTweETHDec24 is BaseFeedPTPendle { | ||
string public constant description = "PT-weETH/weETH Oracle"; | ||
|
||
constructor( | ||
IAccessControlManager accessControlManager, | ||
uint256 _maxImpliedRate, | ||
uint32 _twapDuration | ||
) BaseFeedPTPendle(accessControlManager, _maxImpliedRate, _twapDuration) {} | ||
|
||
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
OVERRIDES | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function asset() public pure override returns (address) { | ||
return 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee; | ||
} | ||
|
||
function sy() public pure override returns (address) { | ||
return 0xAC0047886a985071476a1186bE89222659970d65; | ||
} | ||
|
||
function maturity() public pure override returns (uint256) { | ||
return 1735171200; | ||
} | ||
|
||
function market() public pure override returns (address) { | ||
return 0x7d372819240D14fB477f17b964f95F33BeB4c704; | ||
} | ||
} |
Submodule forge-std
updated
32 files
+6 −12 | .github/workflows/ci.yml | |
+3 −1 | .github/workflows/sync.yml | |
+0 −3 | .gitmodules | |
+1 −1 | README.md | |
+3 −3 | foundry.toml | |
+0 −1 | lib/ds-test | |
+1 −1 | package.json | |
+1 −1 | scripts/vm.py | |
+518 −225 | src/StdAssertions.sol | |
+12 −8 | src/StdChains.sol | |
+9 −3 | src/StdInvariant.sol | |
+7 −11 | src/StdJson.sol | |
+201 −106 | src/StdStorage.sol | |
+179 −0 | src/StdToml.sol | |
+1 −1 | src/StdUtils.sol | |
+4 −4 | src/Test.sol | |
+647 −7 | src/Vm.sol | |
+51 −33 | src/mocks/MockERC20.sol | |
+46 −36 | src/mocks/MockERC721.sol | |
+39 −909 | test/StdAssertions.t.sol | |
+33 −26 | test/StdChains.t.sol | |
+19 −11 | test/StdCheats.t.sol | |
+49 −0 | test/StdJson.t.sol | |
+8 −8 | test/StdMath.t.sol | |
+159 −11 | test/StdStorage.t.sol | |
+49 −0 | test/StdToml.t.sol | |
+18 −18 | test/StdUtils.t.sol | |
+3 −3 | test/Vm.t.sol | |
+8 −0 | test/fixtures/test.json | |
+6 −0 | test/fixtures/test.toml | |
+1 −1 | test/mocks/MockERC20.t.sol | |
+1 −1 | test/mocks/MockERC721.t.sol |
Submodule utils
updated
4 files
+1 −1 | lib/forge-std | |
+314 −236 | src/CommonUtils.sol | |
+6 −1 | src/Constants.sol | |
+37 −0 | utils/getConnectedChains.js |
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
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "./MorphoFeedPTPendle.t.sol"; | ||
import { IAccessControlManager } from "borrow-contracts/interfaces/IAccessControlManager.sol"; | ||
|
||
contract MorphoFeedPTweETHDec24Test is MorphoFeedPTPendleTest { | ||
using stdStorage for StdStorage; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
_TWAP_DURATION = 30 minutes; | ||
_STALE_PERIOD = 24 hours; | ||
_MAX_IMPLIED_RATE = 0.4 ether; | ||
|
||
_oracle = new MorphoFeedPTweETHDec24( | ||
IAccessControlManager(address(coreBorrow)), | ||
_MAX_IMPLIED_RATE, | ||
_TWAP_DURATION | ||
); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
CORE LOGIC | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function test_Description_Success() public { | ||
assertEq(_oracle.description(), "PT-weETH/weETH Oracle"); | ||
} | ||
|
||
function test_Simple_Success() public { | ||
(, int256 answer, , , ) = _oracle.latestRoundData(); | ||
uint256 value = uint256(answer); | ||
|
||
assertApproxEqAbs(value, 0.8 ether, 0.01 ether); | ||
} | ||
|
||
function test_EconomicalLowerBound_tooSmall() public { | ||
vm.prank(_governor); | ||
_oracle.setMaxImpliedRate(uint256(1e1)); | ||
uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); | ||
|
||
(, int256 answer, , , ) = _oracle.latestRoundData(); | ||
uint256 value = uint256(answer); | ||
|
||
assertEq(value, pendleAMMPrice); | ||
} | ||
|
||
function test_AfterMaturity_Success() public { | ||
// Adavnce to the PT maturity | ||
vm.warp(_oracle.maturity()); | ||
|
||
uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); | ||
(, int256 answer, , , ) = _oracle.latestRoundData(); | ||
uint256 value = uint256(answer); | ||
|
||
assertEq(value, pendleAMMPrice); | ||
assertEq(value, 1 ether); | ||
} | ||
|
||
function test_HackRemove_Success(uint256 slash) public { | ||
slash = bound(slash, 1, BASE_18); | ||
// Remove part of the SY backing collateral to simulate a hack | ||
IERC20 weETH = IERC20(address(_oracle.asset())); | ||
uint256 prevBalance = weETH.balanceOf(_oracle.sy()); | ||
uint256 postBalance = (prevBalance * slash) / BASE_18; | ||
deal(address(weETH), _oracle.sy(), postBalance); | ||
|
||
uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); | ||
(, int256 answer, , , ) = _oracle.latestRoundData(); | ||
uint256 value = uint256(answer); | ||
|
||
assertLe(value, (lowerBound * slash) / BASE_18); | ||
if (slash > 0) assertGe(value, (lowerBound * (slash - 1)) / BASE_18); | ||
} | ||
|
||
function test_HackExpand_Success(uint256 expand) public { | ||
expand = bound(expand, BASE_18, BASE_18 * 1e7); | ||
// Remove part of the SY backing collateral to simulate a hack | ||
IERC20 weETH = IERC20(address(_oracle.asset())); | ||
uint256 prevBalance = weETH.balanceOf(_oracle.sy()); | ||
uint256 postBalance = (prevBalance * expand) / BASE_18; | ||
deal(address(weETH), _oracle.sy(), postBalance); | ||
|
||
uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); | ||
(, int256 answer, , , ) = _oracle.latestRoundData(); | ||
uint256 value = uint256(answer); | ||
|
||
assertEq(value, lowerBound); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / Slither
Local variable shadowing Low