NodeJS 尝试使用uniswap SDK获取现货价格,但交易抛出错误LOK?

bkhjykvo  于 2023-02-08  发布在  Node.js
关注(0)|答案(1)|浏览(268)
const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle(
    immutables.token0,
    immutables.token1,
    immutables.fee,
    amountIn,
    0
  )

我创建了两个erc20虚拟代币,并使用uniswapV3Factory createPool()方法为它们创建了一个池,并获得了池地址。但是当我想使用上面的脚本获取代币的现货价格时,它抛出了以下错误:

Error: call revert exception; VM Exception while processing transaction: reverted with reason string "LOK" [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="quoteExactInputSingle(address,address,uint24,uint256,uint160)", data="0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034c4f4b0000000000000000000000000000000000000000000000000000000000", errorArgs=["LOK"], errorName="Error", errorSignature="Error(string)", reason="LOK", code=CALL_EXCEPTION, version=abi/5.7.0)
    at Logger.makeError (/Users/apple/Desktop/solidity/deploy/node_modules/@ethersproject/contracts/lib/index.js:20:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'LOK',
  code: 'CALL_EXCEPTION',
  method: 'quoteExactInputSingle(address,address,uint24,uint256,uint160)',
  data: '0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034c4f4b0000000000000000000000000000000000000000000000000000000000',
  errorArgs: [ 'LOK' ],
  errorName: 'Error',
  errorSignature: 'Error(string)',
  address: '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6',
  args: [
    '<Token-1-Address>',
    '<Token-2-Address>',
    500,
    BigNumber { _hex: '0x0de0b6b3a7640000', _isBigNumber: true },
    0
  ],
  transaction: {
    data: '0xf7729d4300000000000000000000000008a2e53a8ddd2dd1d895c18928fc63778d97a55a0000000000000000000000006d7a02e23505a74143199abb5fb07e6ea20c6d6300000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000',
    to: '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6'
  }
}
5ssjco0h

5ssjco0h1#

我发现问题出在您提供的令牌地址上,例如token0是WETH9,您必须提供确切的WETH9令牌地址,您可以在www.example.com上找到它etherscan.io

相关问题