Skip to content

Commit 42b004b

Browse files
authored
Merge pull request #75 from morpho-org/refactor/repo
refactor repo
2 parents 281921c + bf37d41 commit 42b004b

14 files changed

+75
-54
lines changed

src/ChainlinkOracle.sol renamed to src/morpho-chainlink-v1/ChainlinkOracle.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
pragma solidity 0.8.21;
33

44
import {IChainlinkOracle} from "./interfaces/IChainlinkOracle.sol";
5-
import {IOracle} from "../lib/morpho-blue/src/interfaces/IOracle.sol";
5+
import {IOracle} from "../../lib/morpho-blue/src/interfaces/IOracle.sol";
66

7-
import {MinimalAggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol";
7+
import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol";
88
import {IERC4626, VaultLib} from "./libraries/VaultLib.sol";
99
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
10-
import {Math} from "../lib/openzeppelin-contracts/contracts/utils/math/Math.sol";
10+
import {Math} from "../../lib/openzeppelin-contracts/contracts/utils/math/Math.sol";
1111

1212
/// @title ChainlinkOracle
1313
/// @author Morpho Labs
@@ -16,7 +16,7 @@ import {Math} from "../lib/openzeppelin-contracts/contracts/utils/math/Math.sol"
1616
contract ChainlinkOracle is IChainlinkOracle {
1717
using Math for uint256;
1818
using VaultLib for IERC4626;
19-
using ChainlinkDataFeedLib for MinimalAggregatorV3Interface;
19+
using ChainlinkDataFeedLib for AggregatorV3Interface;
2020

2121
/* IMMUTABLES */
2222

@@ -27,16 +27,16 @@ contract ChainlinkOracle is IChainlinkOracle {
2727
uint256 public immutable VAULT_CONVERSION_SAMPLE;
2828

2929
/// @inheritdoc IChainlinkOracle
30-
MinimalAggregatorV3Interface public immutable BASE_FEED_1;
30+
AggregatorV3Interface public immutable BASE_FEED_1;
3131

3232
/// @inheritdoc IChainlinkOracle
33-
MinimalAggregatorV3Interface public immutable BASE_FEED_2;
33+
AggregatorV3Interface public immutable BASE_FEED_2;
3434

3535
/// @inheritdoc IChainlinkOracle
36-
MinimalAggregatorV3Interface public immutable QUOTE_FEED_1;
36+
AggregatorV3Interface public immutable QUOTE_FEED_1;
3737

3838
/// @inheritdoc IChainlinkOracle
39-
MinimalAggregatorV3Interface public immutable QUOTE_FEED_2;
39+
AggregatorV3Interface public immutable QUOTE_FEED_2;
4040

4141
/// @inheritdoc IChainlinkOracle
4242
uint256 public immutable SCALE_FACTOR;
@@ -63,10 +63,10 @@ contract ChainlinkOracle is IChainlinkOracle {
6363
/// @param quoteTokenDecimals Quote token decimals.
6464
constructor(
6565
IERC4626 vault,
66-
MinimalAggregatorV3Interface baseFeed1,
67-
MinimalAggregatorV3Interface baseFeed2,
68-
MinimalAggregatorV3Interface quoteFeed1,
69-
MinimalAggregatorV3Interface quoteFeed2,
66+
AggregatorV3Interface baseFeed1,
67+
AggregatorV3Interface baseFeed2,
68+
AggregatorV3Interface quoteFeed1,
69+
AggregatorV3Interface quoteFeed2,
7070
uint256 vaultConversionSample,
7171
uint256 baseTokenDecimals,
7272
uint256 quoteTokenDecimals
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.5.0;
3+
4+
/// @dev From
5+
/// https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol
6+
interface AggregatorV3Interface {
7+
function decimals() external view returns (uint8);
8+
9+
function description() external view returns (string memory);
10+
11+
function version() external view returns (uint256);
12+
13+
function getRoundData(uint80 _roundId)
14+
external
15+
view
16+
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
17+
18+
function latestRoundData()
19+
external
20+
view
21+
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
22+
}

src/interfaces/IChainlinkOracle.sol renamed to src/morpho-chainlink-v1/interfaces/IChainlinkOracle.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
pragma solidity >=0.5.0;
33

44
import {IERC4626} from "./IERC4626.sol";
5-
import {IOracle} from "../../lib/morpho-blue/src/interfaces/IOracle.sol";
6-
import {MinimalAggregatorV3Interface} from "./MinimalAggregatorV3Interface.sol";
5+
import {AggregatorV3Interface} from "./AggregatorV3Interface.sol";
6+
import {IOracle} from "../../../lib/morpho-blue/src/interfaces/IOracle.sol";
77

88
/// @title IChainlinkOracle
99
/// @author Morpho Labs
@@ -17,16 +17,16 @@ interface IChainlinkOracle is IOracle {
1717
function VAULT_CONVERSION_SAMPLE() external view returns (uint256);
1818

1919
/// @notice Returns the address of the first Chainlink base feed.
20-
function BASE_FEED_1() external view returns (MinimalAggregatorV3Interface);
20+
function BASE_FEED_1() external view returns (AggregatorV3Interface);
2121

2222
/// @notice Returns the address of the second Chainlink base feed.
23-
function BASE_FEED_2() external view returns (MinimalAggregatorV3Interface);
23+
function BASE_FEED_2() external view returns (AggregatorV3Interface);
2424

2525
/// @notice Returns the address of the first Chainlink quote feed.
26-
function QUOTE_FEED_1() external view returns (MinimalAggregatorV3Interface);
26+
function QUOTE_FEED_1() external view returns (AggregatorV3Interface);
2727

2828
/// @notice Returns the address of the second Chainlink quote feed.
29-
function QUOTE_FEED_2() external view returns (MinimalAggregatorV3Interface);
29+
function QUOTE_FEED_2() external view returns (AggregatorV3Interface);
3030

3131
/// @notice Returns the price scale factor, calculated at contract creation.
3232
function SCALE_FACTOR() external view returns (uint256);

src/libraries/ChainlinkDataFeedLib.sol renamed to src/morpho-chainlink-v1/libraries/ChainlinkDataFeedLib.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
pragma solidity ^0.8.0;
33

4-
import {MinimalAggregatorV3Interface} from "../interfaces/MinimalAggregatorV3Interface.sol";
4+
import {AggregatorV3Interface} from "../interfaces/AggregatorV3Interface.sol";
55

66
import {ErrorsLib} from "./ErrorsLib.sol";
77

@@ -17,7 +17,7 @@ library ChainlinkDataFeedLib {
1717
/// - Staleness is not checked because it's assumed that the Chainlink feed keeps its promises on this.
1818
/// - The price is not checked to be in the min/max bounds because it's assumed that the Chainlink feed keeps its
1919
/// promises on this.
20-
function getPrice(MinimalAggregatorV3Interface feed) internal view returns (uint256) {
20+
function getPrice(AggregatorV3Interface feed) internal view returns (uint256) {
2121
if (address(feed) == address(0)) return 1;
2222

2323
(, int256 answer,,,) = feed.latestRoundData();
@@ -28,7 +28,7 @@ library ChainlinkDataFeedLib {
2828

2929
/// @dev Returns the number of decimals of a `feed`.
3030
/// @dev When `feed` is the address zero, returns 0.
31-
function getDecimals(MinimalAggregatorV3Interface feed) internal view returns (uint256) {
31+
function getDecimals(AggregatorV3Interface feed) internal view returns (uint256) {
3232
if (address(feed) == address(0)) return 0;
3333

3434
return feed.decimals();

src/libraries/ErrorsLib.sol renamed to src/morpho-chainlink-v1/libraries/ErrorsLib.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ library ErrorsLib {
1414

1515
/// @notice Thrown when the vault conversion sample is not 1 while vault = address(0).
1616
string constant VAULT_CONVERSION_SAMPLE_IS_NOT_ONE = "vault conversion sample is not one";
17-
18-
/// @notice Thrown when the zero address is passed as argument.
19-
string constant ZERO_ADDRESS = "zero address";
2017
}

src/adapters/WstEthEthExchangeRateChainlinkAdapter.sol renamed to src/wsteth-exchange-rate-adapter/WstEthEthExchangeRateChainlinkAdapter.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
pragma solidity 0.8.21;
33

4-
import {IWstEth} from "../interfaces/IWstEth.sol";
5-
import {MinimalAggregatorV3Interface} from "../interfaces/MinimalAggregatorV3Interface.sol";
4+
import {IWstEth} from "./interfaces/IWstEth.sol";
5+
import {MinimalAggregatorV3Interface} from "./interfaces/MinimalAggregatorV3Interface.sol";
66

7-
import {ErrorsLib} from "../libraries/ErrorsLib.sol";
7+
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
88

99
/// @title WstEthEthExchangeRateChainlinkAdapter
1010
/// @author Morpho Labs

0 commit comments

Comments
 (0)