Blockchain technology is the fundamental technology of Web3.0, which can provide decentralized trust and security guarantees.
Blockchain is a distributed database that stores information about all transactions, with each block containing the hash value of the previous block, forming an immutable chain.
Decentralized storage refers to storing data on multiple nodes, rather than concentrating it on a centralized server.
This technology can improve the security and reliability of data, and can achieve higher data access speeds.
Decentralized storage can be applied to various scenarios, such as cloud storage, file sharing, backup and recovery, etc.
The development of blockchain has entered the era of token economy. The token economy is an economic form born in the era of digital economy, which is driven by the value of token to change relations of production and promote the development of productivity.
//if fee is on,mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0,uint112 _reserve1)private returns(bool feeOn){
address feeTo=IUniswapV2Factory(factory).feeTo();
feeOn=feeTo!=address(0);
uint _kLast=kLast;//gas savings
if(feeOn){
if(_kLast!=0){
uint rootK=Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast=Math.sqrt(_kLast);
if(rootK>rootKLast){
uint numerator=totalSupply.mul(rootK.sub(rootKLast));
uint denominator=rootK.mul(5).add(rootKLast);
uint liquidity=numerator/denominator;
if(liquidity>0)_mint(feeTo,liquidity);
}
}
}
else if(_kLast!=0){
kLast=0;
}
}
//this low-level function should be called from a contract which performs important safety checks
//这个低级函数应该从执行重要安全检查的合约中调用
function mint(address to)external lock returns(uint liquidity){
(uint112 _reserve0,uint112 _reserve1,)=getReserves();//gas savings
//合约里两种token的当前的balance
uint balance0=IERC20(token0).balanceOf(address(this));
uint balance1=IERC20(token1).balanceOf(address(this));
uint amount0=balance0.sub(_reserve0);
uint amount1=balance1.sub(_reserve1);
bool feeOn=_mintFee(_reserve0,_reserve1);
uint _totalSupply=totalSupply;//gas savings,must be defined here since totalSupply can update in _mintFee
if(_totalSupply==0){
_mint(address(0),MINIMUM_LIQUIDITY);//permanently lock the first MINIMUM_LIQUIDITY tokens
}else{
liquidity=Math.min(amount0.mul(_totalSupply)/_reserve0,amount1.mul(_totalSupply)/_reserve1);
}