楼主: v薇18038319724
449 0

智能合约互助公排流动性质押挖矿系统开发(详情开发及源码) [推广有奖]

  • 0关注
  • 0粉丝

大专生

50%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
13.5485
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
530 点
帖子
27
精华
0
在线时间
7 小时
注册时间
2023-4-3
最后登录
2023-5-12

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

The universe is the successor of the mobile internet,and the doors of the virtual world and the real world have been opened.The metauniverse may become the new direction of the development of the Internet

and may also be the next form of the development of the digital economy.The exploration of the universe will promote the deep integration of the real economy and the digital economy,and promote the digital economy to a new stage.

  //given some amount of an asset and pair reserves,returns an equivalent amount of the other asset

  //添加流动性的时候,通过该方法查询输入A的数量,需要多少个B

  function quote(uint amountA,uint reserveA,uint reserveB)internal pure returns(uint amountB){

  //判断数量,首次添加流动性,随意定价,不需要查询该方法

  require(amountA>0,'UniswapV2Library:INSUFFICIENT_AMOUNT');

  require(reserveA>0&&reserveB>0,'UniswapV2Library:INSUFFICIENT_LIQUIDITY');

  //B数量=预期输入A的数量*B的储备量/A的储备量;//实际公式就是A/B=reserveA/reserveB,两个币的数量比例一致

  amountB=amountA.mul(reserveB)/reserveA;

  }

  //given an input amount of an asset and pair reserves,returns the maximum output amount of the other asset

  //通过精确输入金额,输入币的储备量,输出币的储备量,计算输出币的最大输出量

  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');

  //具体看下面的公式推导,要看该公式,首先要理解uniswap AMM,X*Y=K

  uint amountInWithFee=amountIn.mul(997);//手续费都是扣输入额的千三,所以需要去掉千三后才是实际用于交易的金额

  uint numerator=amountInWithFee.mul(reserveOut);//套下面公式理解吧!!

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

  amountOut=numerator/denominator;


二维码

扫码加我 拉你入群

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

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

关键词:流动性 Insufficient Development Integration Exploration

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jr
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 07:16