【问题标题】:I can not get correct amountOut by quoteExactInputSingle -uniswap-v3-quoter我无法通过 quoteExactInputSingle -uniswap-v3-quoter 获得正确的 amountOut
【发布时间】:2022-07-11 23:03:50
【问题描述】:
const Web3 = require("web3")
const fs = require('fs')

let web3 = new Web3('http://127.0.0.1:8545')

let myABI = JSON.parse(fs.readFileSync('./0_abi/Quoter.abi').toString())

let addrQuoter = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6' // quoter
let addrTokenIn = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' // ETH
let addrTokenOut = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI

let fee = 500 // 0.05%
let amountIn = 3
let sqrtPriceLimitX96 = 0

let myContract = new web3.eth.Contract(myABI, addrQuoter)

myContract.methods.quoteExactInputSingle(
    addrTokenIn,
    addrTokenOut,
    fee,
    amountIn,
    sqrtPriceLimitX96).call((err, res) => {
    if (err) return console.log(err)
    console.log(res)
})

如果 amountIn 为 1,则 res 为 0
如果 amountIn 为 2,res 为 2730,接近真实市场价格
如果 amountIn 为 3,则 res 为 5461,
...
所以实际的 amountIn 是 (amountIn - 1)
为什么?
而且流动性有限。但是随着 amountIn 变大,amountOut 也越大。 \

【问题讨论】:

    标签: javascript pool web3js price uniswap


    【解决方案1】:

    1 表示 1 wei,而不是 1 ether。因此,如果amountIn 为1,则amountIn 完全支付费用。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2021-03-09
    • 2019-09-17
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 2015-09-20
    相关资源
    最近更新 更多