-
Notifications
You must be signed in to change notification settings - Fork 91
/
TWAPOracleDollar3poolFacet.sol
47 lines (42 loc) · 1.67 KB
/
TWAPOracleDollar3poolFacet.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
45
46
47
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;
import {LibTWAPOracle} from "../libraries/LibTWAPOracle.sol";
import {Modifiers} from "../libraries/LibAppStorage.sol";
import {ITWAPOracleDollar3pool} from "../../dollar/interfaces/ITWAPOracleDollar3pool.sol";
/**
* @notice Facet used for Curve TWAP oracle in the Dollar MetaPool
*/
contract TWAPOracleDollar3poolFacet is Modifiers, ITWAPOracleDollar3pool {
/**
* @notice Sets Curve MetaPool to be used as a TWAP oracle
* @param _pool Curve MetaPool address, pool for 2 tokens [Dollar, 3CRV LP]
* @param _curve3CRVToken1 Curve 3Pool LP token address
*/
function setPool(
address _pool,
address _curve3CRVToken1
) external onlyOwner {
return LibTWAPOracle.setPool(_pool, _curve3CRVToken1);
}
/**
* @notice Updates the following state variables to the latest values from MetaPool:
* - Dollar / 3CRV LP quote
* - 3CRV LP / Dollar quote
* - cumulative prices
* - update timestamp
*/
function update() external {
LibTWAPOracle.update();
}
/**
* @notice Returns the quote for the provided `token` address
* @notice If the `token` param is Dollar then returns 3CRV LP / Dollar quote
* @notice If the `token` param is 3CRV LP then returns Dollar / 3CRV LP quote
* @dev This will always return 0 before update has been called successfully for the first time
* @param token Token address
* @return amountOut Token price, Dollar / 3CRV LP or 3CRV LP / Dollar quote
*/
function consult(address token) external view returns (uint256 amountOut) {
return LibTWAPOracle.consult(token);
}
}