forked from Uniswap/v3-periphery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOracleTest.sol
37 lines (32 loc) · 1.16 KB
/
OracleTest.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
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/OracleLibrary.sol';
contract OracleTest {
function consult(address pool, uint32 period) public view returns (int24 timeWeightedAverageTick) {
timeWeightedAverageTick = OracleLibrary.consult(pool, period);
}
function getQuoteAtTick(
int24 tick,
uint128 baseAmount,
address baseToken,
address quoteToken
) public pure returns (uint256 quoteAmount) {
quoteAmount = OracleLibrary.getQuoteAtTick(tick, baseAmount, baseToken, quoteToken);
}
// For gas snapshot test
function getGasCostOfConsult(address pool, uint32 period) public view returns (uint256) {
uint256 gasBefore = gasleft();
OracleLibrary.consult(pool, period);
return gasBefore - gasleft();
}
function getGasCostOfGetQuoteAtTick(
int24 tick,
uint128 baseAmount,
address baseToken,
address quoteToken
) public view returns (uint256) {
uint256 gasBefore = gasleft();
OracleLibrary.getQuoteAtTick(tick, baseAmount, baseToken, quoteToken);
return gasBefore - gasleft();
}
}