-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathOracleTest.sol
More file actions
67 lines (58 loc) · 2.11 KB
/
OracleTest.sol
File metadata and controls
67 lines (58 loc) · 2.11 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
pragma abicoder v2;
import '../libraries/OracleLibrary.sol';
contract OracleTest {
function consult(address pool, uint32 secondsAgo)
public
view
returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
{
return OracleLibrary.consult(pool, secondsAgo);
}
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();
}
function getOldestObservationSecondsAgo(address pool)
public
view
returns (uint32 secondsAgo, uint32 currentTimestamp)
{
secondsAgo = OracleLibrary.getOldestObservationSecondsAgo(pool);
currentTimestamp = uint32(block.timestamp);
}
function getBlockStartingTickAndLiquidity(address pool) public view returns (int24, uint128) {
return OracleLibrary.getBlockStartingTickAndLiquidity(pool);
}
function getWeightedArithmeticMeanTick(OracleLibrary.WeightedTickData[] memory observations)
public
pure
returns (int24 arithmeticMeanWeightedTick)
{
return OracleLibrary.getWeightedArithmeticMeanTick(observations);
}
function getChainedPrice(address[] memory tokens, int24[] memory ticks) public view returns (int256 syntheticTick) {
return OracleLibrary.getChainedPrice(tokens, ticks);
}
}