//规定版本
pragma solidity >=0.5.0;
//导入Pair接口
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
//导入浮点库,什么作用?
import '@uniswap/lib/contracts/libraries/FixedPoint.sol';
//一个记录着对计算平均价格的预言机提供了一些有帮助的方法的库
// library with helper methods for oracles that are concerned with computing average prices
library UniswapV2OracleLibrary {
using FixedPoint for *;
//辅助函数,返回当前区块时间,在uint32的范围内
// helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
//产生一个积累的价格,使用(反事实的)去节省gas以及避免同时的呼叫
// produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
//提交一个交易对,返回两个代币的累计价格、当前区块时间戳
function currentCumulativePrices(
address pair
) internal view returns (ui
UniswapV2OracleLirary.sol
最新推荐文章于 2024-03-06 17:08:45 发布