DAPP/3M互助拆分雙軌公排模式系統(tǒng)開發(fā)方案介紹/成熟技術(shù)/項(xiàng)目邏輯/源碼說明
DAPP是去中心化應(yīng)用程序(Decentralized Application),它是建立在區(qū)塊練技術(shù)之上的應(yīng)用程序,具有去中心化、開放性、透明性、安全性等特點(diǎn),DAPP可以實(shí)現(xiàn)各種功能
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(MintParams calldata params)
external
payable
override
checkDeadline(params.deadline)
returns(
uint256 tokenId,
uint256 amount0,
uint256 amount1
)
{
IUniswapV3Pool pool;
//這里是添加流動性,并完成x token和y token的發(fā)送
(amount0,amount1,pool)=addLiquidity(
AddLiquidityParams({
token0:params.token0,
token1:params.token1,
fee:params.fee,
recipient:address(this),
tickLower:params.tickLower,
tickUpper:params.tickUpper,
amount:params.amount,
amount0Max:params.amount0Max,
amount1Max:params.amount1Max
})
);
//鑄造ERC721 token給用戶,用來代表用戶所持有的流動性
_mint(params.recipient,(tokenId=_nextId++));
bytes32 positionKey=PositionKey.compute(address(this),params.tickLower,params.tickUpper);
(,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128,,)=pool.positions(positionKey);
//idempotent set
uint80 poolId=
cachePoolKey(
address(pool),
PoolAddress.PoolKey({token0:params.token0,token1:params.token1,fee:params.fee})
);
//用ERC721的token
_positions[tokenId]=Position({
nonce:0,
operator:address(0),
poolId:poolId,
tickLower:params.tickLower,
tickUpper:params.tickUpper,
liquidity:params.amount,
feeGrowthInside0LastX128:feeGrowthInside0LastX128,
feeGrowthInside1LastX128:feeGrowthInside1LastX128,
tokensOwed0:0,
tokensOwed1:0
});
}