全部版块 我的主页
论坛 金融投资论坛 六区 金融实务版 比特币、区块链与元宇宙
1071 0
2023-04-17

The"sharing"of the metauniverse ontology can be expressed in the form of standardization,which is the best order obtained by consensus within a certain range on the basis of scientific research and theoretical practice.The standards of the universe can be divided into five categories:basic,technology and platform

  function getAmountOut(uint amountIn,uint reserveIn,uint reserveOut)internal pure returns(uint amountOut){

  require(amountIn>0,'UniswapV2Library:INSUFFICIENT_INPUT_AMOUNT');

  require(reserveIn>0&&reserveOut>0,'UniswapV2Library:INSUFFICIENT_LIQUIDITY');

  uint amountInWithFee=amountIn.mul(997);

  uint numerator=amountInWithFee.mul(reserveOut);

  uint denominator=reserveIn.mul(1000).add(amountInWithFee);

  amountOut=numerator/denominator;

  }
  //给定资产的输出量和对准备金,返回其他资产所需的输入量

  //(x+a)(y-b)=xy

  //a=bx/(y-b)

  //考虑手续费:

  //实际a`=a*1000/997

  function getAmountIn(uint amountOut,uint reserveIn,uint reserveOut)internal pure returns(uint amountIn){

  require(amountOut>0,'UniswapV2Library:INSUFFICIENT_OUTPUT_AMOUNT');

  require(reserveIn>0&&reserveOut>0,'UniswapV2Library:INSUFFICIENT_LIQUIDITY');

  uint numerator=reserveIn.mul(amountOut).mul(1000);

  uint denominator=reserveOut.sub(amountOut).mul(997);

  //加一是防止数据溢出

  amountIn=(numerator/denominator).add(1);

  }

  function getAmountsOut(address factory,uint amountIn,address[]memory path)internal view returns(uint[]memory amounts){

  require(path.length>=2,'UniswapV2Library:INVALID_PATH');

  amounts=new uint[](path.length);

  amounts[0]=amountIn;

  for(uint i;i<path.length-1;i++){

  (uint reserveIn,uint reserveOut)=getReserves(factory,path<i>,path[i+1]);

  amounts[i+1]=getAmountOut(amounts<i>,reserveIn,reserveOut);

  }

  }

  data and protocol,content and asset,application and service,governance and supervision.Basic standards establish a common language environment for other standards,including terms,ontology and classification,code and identification,reference architecture,etc.


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群