新零售,即个人、企业以互联网为依托,通过运用大数据、人工智能等先进技术手段,对商品的生产、流通与销售过程进行升级改造,进而重塑业态结构与生态圈,并对线上服务、线下体验以及现代物流进行深度融合的零售新模式。
个人、企业以互联网为依托,通过运用大数据、人工智能等先进技术手段,对商品的生产、流通与销售过程进行升级改造,进而重塑业态结构与生态圈,并对线上服务、线下体验以及现代物流进行深度融合的零售新模式。
源码说明:首次添加和二次添加lp算法有点差别
查找pair和创建pair,使用了create2,有需要可以具体了解
uniswap v2都是两个erc20组合成一个交易对,跟eth相关的内部都是使用的weth交易
交易方法中都是in/out,相对于pair,方法中swapExactTokensForTokens,for的两侧带有Exact的,表示该侧的数是固定的精确数,另一边的数量是需要看实际成交时交易池情况,所以也就有了amountOutMin,amountInMax
_swap和_swapSupportingFeeOnTransferTokens的差别是前者是输入参数的数计算得来的amounts,后者是以交易对实际得到的数去计算
/**
*Submitted for verification at Etherscan.io on
*/
pragma solidity=0.6.6;
interface IUniswapV2Factory{
event PairCreated(address indexed token0,address indexed token1,address pair,uint);
function feeTo()external view returns(address);
function feeToSetter()external view returns(address);
function getPair(address tokenA,address tokenB)external view returns(address pair);
function allPairs(uint)external view returns(address pair);
function allPairsLength()external view returns(uint);
function createPair(address tokenA,address tokenB)external returns(address pair);
function setFeeTo(address)external;
function setFeeToSetter(address)external;
}
interface IUniswapV2Pair{
event Approval(address indexed owner,address indexed spender,uint value);
event Transfer(address indexed from,address indexed to,uint value);
function name()external pure returns(string memory);
function symbol()external pure returns(string memory);
function decimals()external pure returns(uint8);
function totalSupply()external view returns(uint);
function balanceOf(address owner)external view returns(uint);
function allowance(address owner,address spender)external view returns(uint);
function approve(address spender,uint value)external returns(bool);
function transfer(address to,uint value)external returns(bool);
function transferFrom(address from,address to,uint value)external returns(bool);
function DOMAIN_SEPARATOR()external view returns(bytes32);
function PERMIT_TYPEHASH()external pure returns(bytes32);
function nonces(address owner)external view returns(uint);
function permit(address owner,address spender,uint value,uint deadline,uint8 v,bytes32 r,bytes32 s)external;
event Mint(address indexed sender,uint amount0,uint amount1);
event Burn(address indexed sender,uint amount0,uint amount1,address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
)external returns(uint[]memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[]calldata path,
address to,
uint deadline
)external returns(uint[]memory amounts);
function swapExactETHForTokens(uint amountOutMin,address[]calldata path,address to,uint deadline)
external
payable
returns(uint[]memory amounts);
function swapTokensForExactETH(uint amountOut,uint amountInMax,address[]calldata path,address to,uint deadline)
external
returns(uint[]memory amounts);
function swapExactTokensForETH(uint amountIn,uint amountOutMin,address[]calldata path,address to,uint deadline)
external
returns(uint[]memory amounts);
function swapETHForExactTokens(uint amountOut,address[]calldata path,address to,uint deadline)
external
payable
returns(uint[]memory amounts);
function quote(uint amountA,uint reserveA,uint reserveB)external pure returns(uint amountB);
function getAmountOut(uint amountIn,uint reserveIn,uint reserveOut)external pure returns(uint amountOut);
function getAmountIn(uint amountOut,uint reserveIn,uint reserveOut)external pure returns(uint amountIn);
function getAmountsOut(uint amountIn,address[]calldata path)external view returns(uint[]memory amounts);
function getAmountsIn(uint amountOut,address[]calldata path)external view returns(uint[]memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01{
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
)external returns(uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax,uint8 v,bytes32 r,bytes32 s
)external returns(uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[]calldata path,
address to,
uint deadline
)external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[]calldata path,
address to,
uint deadline
)external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[]calldata path,
address to,
uint deadline
)external;
}