Web3.0的特点是使用区块链和其他赋能技术,如AI和密码学,以创建一个更公平、安全和私有的在线生态系统。
web3.0的发展趋势是创建分散的网络、协议和应用程序,以无信任和安全的方式促进价值和信息的交换。
随着区块链技术的发展,DeFi(去中心化金融)应运而生。其中,以智能合约为基础的流动性质押挖矿(Liquidity Staking
Mining)成为了各大平台竞相推出的重要功能。普瑞缇(ProTradex)是一家基于马蹄链(Polygon)开发的去中心化交易平台,其推出的PRT代币也可以用于质押挖矿。
function _safeTransfer(address token,address to,uint value)private{
(bool success,bytes memory data)=token.call(abi.encodeWithSelector(SELECTOR,to,value));
require(success&&(data.length==0||abi.decode(data,(bool))),'UniswapV2:TRANSFER_FAILED');
}
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
);
event Sync(uint112 reserve0,uint112 reserve1);
constructor()public{
factory=msg.sender;
}
//called once by the factory at time of deployment
function initialize(address _token0,address _token1)external{
require(msg.sender==factory,'UniswapV2:FORBIDDEN');//sufficient check
token0=_token0;
token1=_token1;
}
//update reserves and,on the first call per block,price accumulators
function _update(uint balance0,uint balance1,uint112 _reserve0,uint112 _reserve1)private{
require(balance0<=uint112(-1)&&balance1<=uint112(-1),'UniswapV2:OVERFLOW');
uint32 blockTimestamp=uint32(block.timestamp%2**32);
uint32 timeElapsed=blockTimestamp-blockTimestampLast;//overflow is desired
if(timeElapsed>0&&_reserve0!=0&&_reserve1!=0){
//*never overflows,and+overflow is desired
price0CumulativeLast+=uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0))*timeElapsed;
price1CumulativeLast+=uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1))*timeElapsed;
}
reserve0=uint112(balance0);
reserve1=uint112(balance1);
blockTimestampLast=blockTimestamp;
emit Sync(reserve0,reserve1);
}