我无法通过 quoteExactInputSingle -uniswap-v3-quoter 获得正确的 amountOut
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 也会变大。 \
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)
})
if amountIn is 1, res is 0
if amountIn is 2, res is 2730, close to the real market price
if amountIn is 3, res is 5461,
...
so the real amountIn is (amountIn - 1)
why?
And the liquidity is limited. But as the amountIn become bigger, the amountOut is bigger. \
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1 表示 1 wei,而不是 1 ether。因此,如果 amountIn 为 1,则 amountIn 已全部支付费用。
1 means 1 wei, not 1 ether. So, if amountIn is 1, the amountIn is paid for fee totally.