周边合约
Uniswap V2周边合约的主要就是作为外部账户与核心合约之间的桥梁,Uniswap V2的周边合约包含了接口定义、工具类库、Router和示例实现四部分内容:
下面我们逐一进行介绍:
UniswapV2Library
UniswapV2Libray合约源码如下所示:
pragma solidity >=0.5.0;
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import "./SafeMath.sol";
library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
requir