infrastructure-upgrade/lib/v3-periphery/contracts/test/OracleTest.sol
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

38 lines
1.2 KiB
Solidity

// 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();
}
}