Solidity

Uniswap V3:quoteExactInputSingle 對 USDC-CVX 拋出意外錯誤,但對 USDC-WETH 工作正常

  • October 9, 2022

我正在使用quoteExactInputSingle獲取不同代幣的兌換金額輸出,該實現適用於 USDC-WETH 對,但不適用於 USDC 和 CVX 對。

當我試圖在 USDC 和 CVX 之間進行交換時,它會拋出一個錯誤:

const amountOut = await quoterContract.callStatic.quoteExactInputSingle(
   '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
   '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
   100,
   1_000_000,
   0
 );

但我在下面得到一個錯誤:

{
 reason: 'Unexpected error',
 code: 'CALL_EXCEPTION',
 method: 'quoteExactInputSingle(address,address,uint24,uint256,uint160)',
 data: '0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010556e6578706563746564206572726f7200000000000000000000000000000000',
 errorArgs: [ 'Unexpected error' ],
 errorName: 'Error',
 errorSignature: 'Error(string)',
 address: '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6',
 args: [
   '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
   '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
   100,
   '1000000',
   0
 ],
 transaction: {
   data: '0xf7729d43000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000000',
   to: '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6'
 }
}

您的參數有幾個問題:

  1. CVX 令牌地址0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b全部採用小寫格式。通常在使用 Web3 地址時,您需要以校驗和格式提供它們,例如:0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B.
  2. 您正在使用100USDC/CVX 掉期的費用等級(0.01% 掉期費用)。只有少數 0.01% 的礦池存在,而且很可能尚未創建 USDC/CVX 礦池。選擇另一個費用等級並檢查是否存在諸如池。

引用自:https://ethereum.stackexchange.com/questions/137120