From 0b9bbb374d3500cd71437b98c87528c87da37fa7 Mon Sep 17 00:00:00 2001 From: gs8nrv <55771972+GuillaumeNervoXS@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:12:36 +0100 Subject: [PATCH] fix lint errors --- contracts/oracle/BaseOraclePTPendle.sol | 18 +++++++------- .../mainnet/EUR/OraclePTweETHEUR.sol | 8 +++---- lib/abdk-libraries-solidity | 1 - .../oracles/pendle/BaseOraclePendlePT.t.sol | 24 +++++++++---------- .../oracles/pendle/OraclePTweETH.t.sol | 22 ++++++++--------- 5 files changed, 36 insertions(+), 37 deletions(-) delete mode 160000 lib/abdk-libraries-solidity diff --git a/contracts/oracle/BaseOraclePTPendle.sol b/contracts/oracle/BaseOraclePTPendle.sol index 23b7124b..614d4386 100644 --- a/contracts/oracle/BaseOraclePTPendle.sol +++ b/contracts/oracle/BaseOraclePTPendle.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; -import { UNIT, UD60x18, ud, intoUint256 } from "prb/math/UD60x18.sol"; +import { UNIT, UD60x18, ud } from "prb/math/UD60x18.sol"; import "pendle/interfaces/IPMarket.sol"; import { PendlePtOracleLib } from "pendle/oracles/PendlePtOracleLib.sol"; import "../interfaces/ITreasury.sol"; @@ -58,7 +58,7 @@ abstract contract BaseOraclePTPendle { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ function _economicalPTLowerBoundPrice() internal view returns (uint256) { - uint256 exp = block.timestamp > MATURITY() ? 0 : MATURITY() - block.timestamp; + uint256 exp = block.timestamp > maturity() ? 0 : maturity() - block.timestamp; if (exp == 0) return BASE_18; UD60x18 denominator = UNIT.add(ud(maxImpliedRate)).pow(ud(exp).div(ud(YEAR))); @@ -67,12 +67,12 @@ abstract contract BaseOraclePTPendle { } function _pendlePTPrice() internal view returns (uint256) { - return PendlePtOracleLib.getPtToAssetRate(IPMarket(MARKET()), twapDuration); + return PendlePtOracleLib.getPtToAssetRate(IPMarket(market()), twapDuration); } function _detectHackRatio() internal view returns (uint256) { - uint256 assetBalanceSY = IERC20(ASSET()).balanceOf(SY()); - uint256 totalSupplySY = IERC20(SY()).totalSupply(); + uint256 assetBalanceSY = IERC20(asset()).balanceOf(sy()); + uint256 totalSupplySY = IERC20(sy()).totalSupply(); return assetBalanceSY > totalSupplySY ? BASE_18 : (assetBalanceSY * BASE_18) / totalSupplySY; } @@ -80,13 +80,13 @@ abstract contract BaseOraclePTPendle { OVERRIDES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ - function ASSET() public pure virtual returns (address); + function asset() public pure virtual returns (address); - function SY() public pure virtual returns (address); + function sy() public pure virtual returns (address); - function MATURITY() public pure virtual returns (uint256); + function maturity() public pure virtual returns (uint256); - function MARKET() public pure virtual returns (address); + function market() public pure virtual returns (address); function _onlyGovernorOrGuardian() internal view virtual; } diff --git a/contracts/oracle/implementations/mainnet/EUR/OraclePTweETHEUR.sol b/contracts/oracle/implementations/mainnet/EUR/OraclePTweETHEUR.sol index 2f5bb2e2..7d86b3b8 100644 --- a/contracts/oracle/implementations/mainnet/EUR/OraclePTweETHEUR.sol +++ b/contracts/oracle/implementations/mainnet/EUR/OraclePTweETHEUR.sol @@ -44,19 +44,19 @@ contract OraclePTweETHEUR is BaseOracleChainlinkMultiTwoFeeds, BaseOraclePTPendl OVERRIDES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ - function ASSET() public pure override returns (address) { + function asset() public pure override returns (address) { return 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee; } - function SY() public pure override returns (address) { + function sy() public pure override returns (address) { return 0xAC0047886a985071476a1186bE89222659970d65; } - function MATURITY() public pure override returns (uint256) { + function maturity() public pure override returns (uint256) { return 1719446400; } - function MARKET() public pure override returns (address) { + function market() public pure override returns (address) { return 0xF32e58F92e60f4b0A37A69b95d642A471365EAe8; } diff --git a/lib/abdk-libraries-solidity b/lib/abdk-libraries-solidity deleted file mode 160000 index 5e1e7c11..00000000 --- a/lib/abdk-libraries-solidity +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5e1e7c11b35f8313d3f7ce11c1b86320d7c0b554 diff --git a/test/foundry/oracles/pendle/BaseOraclePendlePT.t.sol b/test/foundry/oracles/pendle/BaseOraclePendlePT.t.sol index 5e15eb5f..7e209fe1 100644 --- a/test/foundry/oracles/pendle/BaseOraclePendlePT.t.sol +++ b/test/foundry/oracles/pendle/BaseOraclePendlePT.t.sol @@ -142,6 +142,7 @@ contract BaseOraclePendlePT is Test { contract BaseOraclePendlePTTest is BaseOraclePendlePT { using stdStorage for StdStorage; + /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SETTERS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ @@ -189,19 +190,19 @@ contract BaseOraclePendlePTTest is BaseOraclePendlePT { function test_EconomicalLowerBound_tooSmall() public { vm.prank(_governor); _oracle.setMaxImpliedRate(uint256(1e1)); - uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.MARKET()), _TWAP_DURATION); + uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); assertEq(_oracle.read(), _read(pendleAMMPrice)); } function test_AfterMaturity_Success() public { // Adavnce to the PT maturity - vm.warp(_oracle.MATURITY()); + vm.warp(_oracle.maturity()); // Update the last timestamp oracle push _updateChainlinkTimestamp(block.timestamp); - uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.MARKET()), _TWAP_DURATION); + uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); uint256 value = _oracle.read(); assertEq(value, _read(pendleAMMPrice)); assertEq(value, _read(1 ether)); @@ -210,12 +211,12 @@ contract BaseOraclePendlePTTest is BaseOraclePendlePT { 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()); + IERC20 weETH = IERC20(address(_oracle.asset())); + uint256 prevBalance = weETH.balanceOf(_oracle.sy()); uint256 postBalance = (prevBalance * slash) / BASE_18; - deal(address(weETH), _oracle.SY(), postBalance); + deal(address(weETH), _oracle.sy(), postBalance); - uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.MATURITY()); + uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); uint256 value = _oracle.read(); assertLe(value, _read((lowerBound * slash) / BASE_18)); @@ -225,15 +226,14 @@ contract BaseOraclePendlePTTest is BaseOraclePendlePT { 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()); + IERC20 weETH = IERC20(address(_oracle.asset())); + uint256 prevBalance = weETH.balanceOf(_oracle.sy()); uint256 postBalance = (prevBalance * expand) / BASE_18; - deal(address(weETH), _oracle.SY(), postBalance); + deal(address(weETH), _oracle.sy(), postBalance); - uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.MATURITY()); + uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); uint256 value = _oracle.read(); assertEq(value, _read((lowerBound))); } } - diff --git a/test/foundry/oracles/pendle/OraclePTweETH.t.sol b/test/foundry/oracles/pendle/OraclePTweETH.t.sol index bd011d8e..90e21ce3 100644 --- a/test/foundry/oracles/pendle/OraclePTweETH.t.sol +++ b/test/foundry/oracles/pendle/OraclePTweETH.t.sol @@ -36,19 +36,19 @@ contract OraclePTweETH is BaseOraclePendlePT { function test_EconomicalLowerBound_tooSmall() public { vm.prank(_governor); _oracle.setMaxImpliedRate(uint256(1e1)); - uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.MARKET()), _TWAP_DURATION); + uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); assertEq(_oracle.read(), _read(pendleAMMPrice)); } function test_AfterMaturity_Success() public { // Adavnce to the PT maturity - vm.warp(_oracle.MATURITY()); + vm.warp(_oracle.maturity()); // Update the last timestamp oracle push _updateChainlinkTimestamp(block.timestamp); - uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.MARKET()), _TWAP_DURATION); + uint256 pendleAMMPrice = PendlePtOracleLib.getPtToAssetRate(IPMarket(_oracle.market()), _TWAP_DURATION); uint256 value = _oracle.read(); assertEq(value, _read(pendleAMMPrice)); assertEq(value, _read(1 ether)); @@ -57,12 +57,12 @@ contract OraclePTweETH is BaseOraclePendlePT { 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()); + IERC20 weETH = IERC20(address(_oracle.asset())); + uint256 prevBalance = weETH.balanceOf(_oracle.sy()); uint256 postBalance = (prevBalance * slash) / BASE_18; - deal(address(weETH), _oracle.SY(), postBalance); + deal(address(weETH), _oracle.sy(), postBalance); - uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.MATURITY()); + uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); uint256 value = _oracle.read(); assertLe(value, _read((lowerBound * slash) / BASE_18)); @@ -72,12 +72,12 @@ contract OraclePTweETH is BaseOraclePendlePT { 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()); + IERC20 weETH = IERC20(address(_oracle.asset())); + uint256 prevBalance = weETH.balanceOf(_oracle.sy()); uint256 postBalance = (prevBalance * expand) / BASE_18; - deal(address(weETH), _oracle.SY(), postBalance); + deal(address(weETH), _oracle.sy(), postBalance); - uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.MATURITY()); + uint256 lowerBound = _economicLowerBound(_MAX_IMPLIED_RATE, _oracle.maturity()); uint256 value = _oracle.read(); assertEq(value, _read((lowerBound)));