【问题标题】:Pancakeswap router v2 - getAmountsOut?Pancakeswap 路由器 v2 - getAmountsOut?
【发布时间】:2022-01-08 23:07:00
【问题描述】:

getAmountsOut/getAmountOut 和 getAmountsIn/getAmountIn 究竟是做什么的? Pancakeswap docs 中没有解释,所以我不确定如何使用它。两者之间有什么区别和's'或没有?

【问题讨论】:

    标签: web3 erc20


    【解决方案1】:

    不同之处在于,带有“s”的那个会返回由path 交换产生的一系列输出。而没有“s”的则返回单个交换的输出。

    所以如果我沿着路径["ETHUSDT", "USDTUSDC"] 进行交换,那么getAmountsOut 将返回来自 ETHUSDT 交换的 USDT 输出量和来自“USDTUSDC”交换的 USDC 输出量。返回值将类似于:[usdtAmount, usdcAmount]

    如果我交换“ETHUSDT”,那么 getAmountOut 将返回 usdtAmount

    getAmountsIn/getAmountIn 的情况正好相反。

    在这里定义:https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/libraries/PancakeLibrary.sol#L63

    【讨论】:

      猜你喜欢
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      相关资源
      最近更新 更多