DAPP是去中心化应用程序(Decentralized Application),它是建立在区块练技术之上的应用程序,具有去中心化、开放性、透明性、安全性等特点,DAPP可以实现各种功能
With the rapid development of the Internet,people are beginning to explore more efficient,secure,and decentralized applications.In this context,the emergence of blockchain technology provides new ideas and solutions for building next-generation decentralized applications(DAPPs).
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
)external override lock returns(uint256 amount0,uint256 amount1){
require(amount>0);
(,int256 amount0Int,int256 amount1Int)=
_modifyPosition(
ModifyPositionParams({
owner:recipient,
tickLower:tickLower,
tickUpper:tickUpper,
liquidityDelta:int256(amount).toInt128()
})
);
amount0=uint256(amount0Int);
amount1=uint256(amount1Int);
uint256 balance0Before;
uint256 balance1Before;
//获取当前池中的x token,y token余额
if(amount0>0)balance0Before=balance0();
if(amount1>0)balance1Before=balance1();
//将需要的x token和y token数量传给回调函数,这里预期回调函数会将指定数量的token发送到合约中
IUniswapV3MintCallback(msg.sender).uniswapV3MintCallback(amount0,amount1,data);
//回调完成后,检查发送至合约的token是否复合预期,如果不满足检查则回滚交易
if(amount0>0)require(balance0Before.add(amount0)<=balance0(),'M0');
if(amount1>0)require(balance1Before.add(amount1)<=balance1(),'M1');
emit Mint(msg.sender,recipient,tickLower,tickUpper,amount,amount0,amount1);
}