-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
* feat: deploy-oracle-PT-Dec-maturity * add ezETH market * fix tests * fix tests * deployed Pendle PT LRT oracles * fix tests * fix Pendle oracles * ezETH feed Morpho compatible * feat: fix PT oracles * deploy new oracles for PTezETH and PTweETH
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.12; | ||
|
||
import { PendlePYOracleLib, PMath } from "pendle/oracles/PendlePYOracleLib.sol"; | ||
import "pendle/interfaces/IPMarket.sol"; | ||
|
||
/// @title FeedPTForSY | ||
/// @author Angle Labs, Inc. | ||
/// @notice Override the BaseFeedPTPendle to provide the price of PT tokens based on the ibToken and not the underlying token | ||
abstract contract FeedPTForSY { | ||
using PMath for uint256; | ||
|
||
/// @dev Depending on the market you should use | ||
/// - getPtToSy() should be used if the underlying token is tradable, | ||
/// - getPtToAsset() if not | ||
/// @dev https://docs.pendle.finance/Developers/Contracts/StandardizedYield#asset-of-sy--assetinfo-function | ||
function _pendlePTPrice(IPMarket _market, uint32 _twapDuration) internal view virtual returns (uint256, uint256) { | ||
(uint256 syIndex, uint256 pyIndex) = PendlePYOracleLib.getSYandPYIndexCurrent(_market); | ||
if (syIndex >= pyIndex) { | ||
return (PendlePYOracleLib.getPtToAssetRateRaw(_market, _twapDuration).divDown(syIndex), syIndex); | ||
} else { | ||
return (PendlePYOracleLib.getPtToAssetRateRaw(_market, _twapDuration).divDown(pyIndex), syIndex); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.12; | ||
|
||
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | ||
|
||
import "../../BaseFeedPTPendle.sol"; | ||
import "../../FeedPTForSY.sol"; | ||
|
||
/// @title MorphoFeedPTezETHDec24 | ||
/// @author Angle Labs, Inc. | ||
/// @notice Gives the price of PT-ezETH in ETH in base 18 | ||
contract MorphoFeedPTezETHDec24 is BaseFeedPTPendle { | ||
string public constant description = "PT-ezETH/ETH Oracle"; | ||
|
||
constructor( | ||
IAccessControlManager accessControlManager, | ||
uint256 _maxImpliedRate, | ||
uint32 _twapDuration | ||
) BaseFeedPTPendle(accessControlManager, _maxImpliedRate, _twapDuration) {} | ||
|
||
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
OVERRIDES | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function asset() public pure override returns (address) { | ||
return 0xbf5495Efe5DB9ce00f80364C8B423567e58d2110; | ||
} | ||
|
||
function sy() public pure override returns (address) { | ||
return 0x22E12A50e3ca49FB183074235cB1db84Fe4C716D; | ||
} | ||
|
||
function maturity() public pure override returns (uint256) { | ||
return 1735171200; | ||
} | ||
|
||
function market() public pure override returns (address) { | ||
return 0xD8F12bCDE578c653014F27379a6114F67F0e445f; | ||
} | ||
} |
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/ETH 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; | ||
} | ||
} |
+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 |
+1 −1 | lib/forge-std | |
+314 −236 | src/CommonUtils.sol | |
+6 −1 | src/Constants.sol | |
+37 −0 | utils/getConnectedChains.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
import "forge-std/Script.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { MorphoFeedPTezETHDec24 } from "borrow-contracts/oracle/morpho/mainnet/MorphoFeedPTezETHDec24.sol"; | ||
import "utils/src/CommonUtils.sol"; | ||
import { IAccessControlManager } from "borrow-contracts/interfaces/IAccessControlManager.sol"; | ||
|
||
contract PTezETHOracleDeploy is Script, CommonUtils { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// TODO | ||
uint256 chainId = CHAIN_ETHEREUM; | ||
address coreBorrow = _chainToContract(chainId, ContractType.CoreBorrow); | ||
uint32 _TWAP_DURATION = 30 minutes; | ||
uint256 _MAX_IMPLIED_RATE = 0.25 ether; | ||
// end TODO | ||
|
||
MorphoFeedPTezETHDec24 oracle = new MorphoFeedPTezETHDec24( | ||
IAccessControlManager(address(coreBorrow)), | ||
_MAX_IMPLIED_RATE, | ||
_TWAP_DURATION | ||
); | ||
(, int256 answer, , , ) = oracle.latestRoundData(); | ||
console.log("oracle value ", uint256(answer)); | ||
console.log("Successfully deployed PT-ezETH: ", address(oracle)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |