admin 管理员组

文章数量: 1086019

I'm using Uniswap V3 to quoteSingleInput of how many token1 I get for token0. WETH/ARB in this case, both having 18 decimals. I've asked ChatGPT how I do it, and it keeps trying to get me to get the gas price in wei

const gasPriceData = (await provider.getFeeData()).gasPrice

But I want the gas price in ARB not wei, to minus it from the the amountOut. Has anyone come across this ? Do I multiply the gasPriceData by anything ? I'm really confused

async function fetchGasToToken(_gasUnits, _token1) {try {const gasCost = new BigNumber(_gasUnits);const gasCostInToken = gasCost.div(new BigNumber(10).pow(_token1.decimals));return gasCostInToken;} catch (error) {console.error("❌ Error converting gas to token1:", error);throw error;}}
const params = {tokenIn: _token0.address,tokenOut: _token1.address,fee: p.fee,amountIn: _amount,sqrtPriceLimitX96: 0,}
const [amountOut, sqrtPriceX96After, initializedTicksCrossed, gasEstimate] =await withTimeout(uniswap_v3.quoter.quoteExactInputSingle.staticCall(params),10000 // 10-second timeout)
const gasInToken = await fetchGasToToken(gasEstimate, _token1) // gasEsimate is 102848
const finalAmount = BigNumber(amountOut).minus(gasInToken);`

I tried dividing gasUnits by the token1 Decimals after multiplying by the power of 10.

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)