字畫/書畫拍賣競拍商城系統(tǒng)開發(fā)(案例開發(fā))/設(shè)計方案/成熟項目/源碼部署
Dapp:代表去中心化應(yīng)用程序。它們是在去中心化網(wǎng)絡(luò)或區(qū)塊鏈上運行后端代碼(主要用Solidity編寫的智能合約)的應(yīng)用程序??梢允褂肦eact、Vue或Angular等前端框架構(gòu)建Dapp。
The technical architecture of dapp mainly includes the following three levels:
Application layer:The application layer refers to the DAPP application that users directly come into contact with,including interface design,interaction methods,user experience,etc.,which needs to fully consider user needs and usage habits.
Protocol layer:The protocol layer refers to the protocols and rules of DAPP,including communication protocols,transaction rules,financial protocols,contract protocols,etc.,which need to ensure their security,stability,and transparency.
Blockchain layer:The blockchain layer is the underlying technical support for DAPP,including blockchain nodes,smart contracts,decentralized storage,consensus algorithms,etc.It requires algorithms and technical means to achieve decentralization,security,and scalability.
function _modifyPosition(ModifyPositionParams memory params)
private
noDelegateCall
returns(
Position.Info storage position,
int256 amount0,
int256 amount1
)
{
...
Slot0 memory _slot0=slot0;//SLOAD for gas optimization
position=_updatePosition(
...
);
...
}
function _modifyPosition(ModifyPositionParams memory params)
private
noDelegateCall
returns(
Position.Info storage position,
int256 amount0,
int256 amount1
)
{
...
if(params.liquidityDelta!=0){
//計算三種情況下amount0和amount1的值,即x token和y token的數(shù)量
if(_slot0.tick<params.tickLower){
amount0=SqrtPriceMath.getAmount0Delta(
//計算lower/upper tick對應(yīng)的價格
TickMath.getSqrtRatioAtTick(params.tickLower),
TickMath.getSqrtRatioAtTick(params.tickUpper),
params.liquidityDelta
);
}else if(_slot0.tick<params.tickUpper){
//current tick is inside the passed range
uint128 liquidityBefore=liquidity;//SLOAD for gas optimization
...
amount0=SqrtPriceMath.getAmount0Delta(
_slot0.sqrtPriceX96,
TickMath.getSqrtRatioAtTick(params.tickUpper),
params.liquidityDelta
);
amount1=SqrtPriceMath.getAmount1Delta(
TickMath.getSqrtRatioAtTick(params.tickLower),
_slot0.sqrtPriceX96,
params.liquidityDelta
);
liquidity=LiquidityMath.addDelta(liquidityBefore,params.liquidityDelta);
}else{
amount1=SqrtPriceMath.getAmount1Delta(
TickMath.getSqrtRatioAtTick(params.tickLower),
TickMath.getSqrtRatioAtTick(params.tickUpper),
params.liquidityDelta
);
}
}
}