getReserves
代码速览
function getReserves()public view returns(uint112 _reserve0,uint112 _reserve1,uint32 _blockTimestampLast){
_reserve0=reserve0; }设计及流程:wwqqyy420
_reserve1=reserve1;
_blockTimestampLast=blockTimestampLast;
}
参数分析
函数getReserves的入参有0个,出参有3个,对应的解释如下:
function getReserves()public view returns(
uint112 _reserve0,//token0的资金池库存数量
uint112 _reserve1,//token1的资金池库存数量
uint32 _blockTimestampLast//上次更新库存的时间price_now=my_token.price()
if price_now>=target_price:
my_token.sell(my_token.balance(),slippage=0.1,speed=1.5)
break
time.sleep(1)
current_value=my_token.price(balance)
target_value=2*current_value
while True:
value_now=my_token.price(my_token.balance())
if value_now>=target_value:
my_token.sell(my_token.balance(),slippage=0.1,speed=1.5)
break
time.sleep(1) }设计及流程:wwqqyy420
_update(balance0,balance1,_reserve0,_reserve1);
emit Swap(msg.sender,amount0In,amount1In,amount0Out,amount1Out,to);
}
//force balances to match reserves
//强制balance以匹配储备
function skim(address to)external lock{