-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathYTokenOracle.sol
44 lines (36 loc) · 1.44 KB
/
YTokenOracle.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 {IOracle} from "../core/IOracle.sol";
interface IYVault {
function token() external view returns (address);
function pricePerShare() external view returns (uint256);
function decimals() external view returns (uint256);
}
/**
@title Yearn YToken Oracle
@notice Price oracle for yToken
*/
contract YTokenOracle is IOracle {
/* -------------------------------------------------------------------------- */
/* STATE VARIABLES */
/* -------------------------------------------------------------------------- */
/// @notice Oracle Facade
IOracle public oracle;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/**
@notice Contract constructor
@param _oracle Address for oracle facade
*/
constructor(IOracle _oracle) {
oracle = _oracle;
}
/// @inheritdoc IOracle
function getPrice(address token) external view returns (uint price) {
address underlying_token = IYVault(token).token();
price = IYVault(token).pricePerShare() *
oracle.getPrice(underlying_token) /
10 ** IYVault(underlying_token).decimals();
}
}