This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERC4626Oracle.sol
44 lines (36 loc) · 1.58 KB
/
ERC4626Oracle.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import "../core/IOracle.sol";
import "./IERC4626.sol";
import "solmate/utils/FixedPointMathLib.sol";
contract ERC4626Oracle is IOracle {
using FixedPointMathLib for uint256;
/* -------------------------------------------------------------------------- */
/* STATE VARIABLES */
/* -------------------------------------------------------------------------- */
/// @notice address of oracle facade
IOracle immutable oracleFacade;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/**
@notice Contract constructor
@param _oracleFacade address oracle facade
*/
constructor(IOracle _oracleFacade) {
oracleFacade = _oracleFacade;
}
/* -------------------------------------------------------------------------- */
/* PUBLIC FUNCTIONS */
/* -------------------------------------------------------------------------- */
/// @inheritdoc IOracle
function getPrice(address token) external view returns (uint) {
uint decimals = IERC4626(token).decimals();
return IERC4626(token).previewRedeem(
10 ** decimals
).mulDivDown(
oracleFacade.getPrice(IERC4626(token).asset()),
10 ** decimals
);
}
}