-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVaultOracleSingle.sol
36 lines (32 loc) · 1003 Bytes
/
VaultOracleSingle.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
//SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "../interfaces/IVaultOracleSingle.sol";
import "../libraries/OracleUtils.sol";
import "@openzeppelin/contracts_5.0.2/token/ERC20/extensions/IERC20Metadata.sol";
contract VaultOracleSingle is IVaultOracleSingle, OracleUtils {
address public feed;
uint128 chainlink_heartbeat;
address public token;
constructor(
address _token,
address _feed,
uint128 _chainlink_heartbeat,
address _uptimeFeedAddress
) OracleUtils(_uptimeFeedAddress) {
feed = _feed;
chainlink_heartbeat = _chainlink_heartbeat;
token = _token;
}
/**
* @dev value in Eth (in wei) of this amount of token
*/
function getTokenPrice(uint256 _amount) external view returns (uint256) {
return
tokenToEth(
_amount,
feed,
chainlink_heartbeat,
IERC20Metadata(token).decimals()
);
}
}