Web 3.0 infrastructure mainly includes node infrastructure, storage, oracle machines, security audits, data analysis platforms, wallets, development tools, etc. For example, the storage of assets on the wallet service user chain is an important entry point for Web 3.0, such as Metamarsk (Cryptocurrency Wallet), WalletConnect (Wallet General Protocol), and so on.
{
//获取tokenA,tokenB的流动池地址
address pair=UniswapV2Library.pairFor(factory,tokenA,tokenB);
//获取授权LP的数量
uint value=approveMax?uint(-1):liquidity;
//授权Router使用用户数量为value的LP
IUniswapV2Pair(pair).permit(msg.sender,address(this),value,deadline,v,r,s);
//移除流动性
(amountA,amountB)=removeLiquidity(tokenA,tokenB,liquidity,amountAMin,amountBMin,to,deadline);
}
function removeLiquidityWithPermit(
address tokenA,//移除流动性tokenA的地址
address tokenB,//移除流动性tokenB的地址
uint liquidity,//销毁LP的数量
uint amountAMin,//获得tokenA数量的最小值
uint amountBMin,//获得tokenB数量的最小值
address to,//获得的tokenA、tokenB发送到的地址
uint deadline,//过期时间
bool approveMax,//是否授权为最大值
uint8 v,bytes32 r,bytes32 s//签名v,r,s
)external virtual override returns(
uint amountA,//实际获得tokenA的数量
uint amountB//实际获得tokenB的数量
){
...
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
)public virtual override ensure(deadline)returns(uint amountToken,uint amountETH){
(amountToken,amountETH)=removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token,to,amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to,amountETH);
}