Skip to content

Commit 08373a0

Browse files
committed
refactor: more coherent file names
1 parent f72e33f commit 08373a0

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/ChainlinkOracle.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ pragma solidity 0.8.19;
44
import {IOracle} from "morpho-blue/interfaces/IOracle.sol";
55

66
import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol";
7-
import {ERC4626, VaultDataFeedLib} from "./libraries/VaultDataFeedLib.sol";
7+
import {ERC4626Interface, VaultLib} from "./libraries/VaultLib.sol";
88

99
/// @title ChainlinkOracle
1010
/// @author Morpho Labs
1111
/// @custom:contact [email protected]
1212
/// @notice Morpho Blue oracle using Chainlink-compliant feeds.
1313
contract ChainlinkOracle is IOracle {
14-
using VaultDataFeedLib for ERC4626;
14+
using VaultLib for ERC4626Interface;
1515
using ChainlinkDataFeedLib for AggregatorV3Interface;
1616

1717
/* IMMUTABLES */
1818

1919
/// @notice Vault.
20-
ERC4626 public immutable VAULT;
20+
ERC4626Interface public immutable VAULT;
2121
/// @notice Vault decimals.
2222
uint256 public immutable VAULT_DECIMALS;
2323
/// @notice First base feed.
@@ -41,7 +41,7 @@ contract ChainlinkOracle is IOracle {
4141
/// @param baseTokenDecimals Base token decimals.
4242
/// @param quoteTokenDecimals Quote token decimals.
4343
constructor(
44-
ERC4626 vault,
44+
ERC4626Interface vault,
4545
AggregatorV3Interface baseFeed1,
4646
AggregatorV3Interface baseFeed2,
4747
AggregatorV3Interface quoteFeed1,

src/interfaces/ERC4626Interface.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
interface ERC4626Interface {
5+
function convertToAssets(uint256) external view returns (uint256);
6+
function decimals() external view returns (uint256);
7+
}

src/libraries/VaultDataFeedLib.sol renamed to src/libraries/VaultLib.sol

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.0;
33

4-
import {AggregatorV3Interface} from "../interfaces/AggregatorV3Interface.sol";
5-
6-
import {ErrorsLib} from "./ErrorsLib.sol";
7-
8-
interface ERC4626 {
9-
function convertToAssets(uint256) external view returns (uint256);
10-
function decimals() external view returns (uint256);
11-
}
4+
import {ERC4626Interface} from "../interfaces/ERC4626Interface.sol";
125

136
/// @title ChainlinkDataFeedLib
147
/// @author Morpho Labs
158
/// @custom:contact [email protected]
169
/// @notice Library exposing functions to interact with a Chainlink-compliant feed.
17-
library VaultDataFeedLib {
10+
library VaultLib {
1811
/// @dev Converts `shares` into the corresponding assets on the `vault`.
1912
/// @dev When `vault` is the address zero, returns 1.
20-
function getAssets(ERC4626 vault, uint256 shares) internal view returns (uint256) {
13+
function getAssets(ERC4626Interface vault, uint256 shares) internal view returns (uint256) {
2114
if (address(vault) == address(0)) return 1;
2215

2316
return vault.convertToAssets(shares);
2417
}
2518

2619
/// @dev Returns the number of decimals of a `vault`, seen as an ERC20.
2720
/// @dev When `vault` is the address zero, returns 0.
28-
function getDecimals(ERC4626 vault) internal view returns (uint256) {
21+
function getDecimals(ERC4626Interface vault) internal view returns (uint256) {
2922
if (address(vault) == address(0)) return 0;
3023

3124
return vault.decimals();

test/ChainlinkOracleTest.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ AggregatorV3Interface constant ethUsdFeed = AggregatorV3Interface(0x5f4eC3Df9cbd
2323
// 18 decimals of precision
2424
AggregatorV3Interface constant daiEthFeed = AggregatorV3Interface(0x773616E4d11A78F511299002da57A0a94577F1f4);
2525

26-
ERC4626 constant vaultZero = ERC4626(address(0));
27-
ERC4626 constant sDaiVault = ERC4626(0x83F20F44975D03b1b09e64809B757c47f942BEeA);
26+
ERC4626Interface constant vaultZero = ERC4626Interface(address(0));
27+
ERC4626Interface constant sDaiVault = ERC4626Interface(0x83F20F44975D03b1b09e64809B757c47f942BEeA);
2828

2929
contract FakeAggregator {
3030
int256 public answer;

0 commit comments

Comments
 (0)