diff --git a/api/_utils.ts b/api/_utils.ts index ecfdf61e8..2f686b0a4 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -1995,11 +1995,14 @@ export function getCachedFillGasUsage( ); // We don't care about the gas token price or the token gas price, only the raw gas units. In the API // we'll compute the gas price separately. + const markups = getGasMarkup(deposit.destinationChainId); const gasCosts = await relayerFeeCalculatorQueries.getGasCosts( buildDepositForSimulation(deposit), overrides?.relayerAddress, { gasPrice, + baseFeeMultiplier: markups.baseFeeMarkup, + priorityFeeMultiplier: markups.priorityFeeMarkup, opStackL1GasCostMultiplier: sdk.utils.chainIsOPStack( deposit.destinationChainId ) diff --git a/api/gas-prices.ts b/api/gas-prices.ts index 2fb63a32b..427da081e 100644 --- a/api/gas-prices.ts +++ b/api/gas-prices.ts @@ -71,10 +71,9 @@ const handler = async ( const relayerFeeCalculatorQueries = getRelayerFeeCalculatorQueries( Number(chainId) ); - const opStackL1GasCostMultiplier = getGasMarkup( - Number(chainId) - ).opStackL1DataFeeMarkup; - const { nativeGasCost, tokenGasCost, opStackL1GasCost } = + const { baseFeeMarkup, priorityFeeMarkup, opStackL1DataFeeMarkup } = + getGasMarkup(Number(chainId)); + const { nativeGasCost, tokenGasCost, opStackL1GasCost, gasPrice } = await relayerFeeCalculatorQueries.getGasCosts( deposit, relayerFeeCalculatorQueries.simulatedRelayerAddress, @@ -82,17 +81,22 @@ const handler = async ( // Pass in the already-computed gasPrice into this query so that the tokenGasCost includes // the scaled gas price, // e.g. tokenGasCost = nativeGasCost * (baseFee * baseFeeMultiplier + priorityFee). + // Except for Linea, where the gas price is dependent on the unsignedTx produced from the deposit, + // so let the SDK compute its gas price here. gasPrice: Number(chainId) === CHAIN_IDs.LINEA ? undefined : gasPrices[i].maxFeePerGas, - opStackL1GasCostMultiplier, + opStackL1GasCostMultiplier: opStackL1DataFeeMarkup, + baseFeeMultiplier: baseFeeMarkup, + priorityFeeMultiplier: priorityFeeMarkup, } ); return { nativeGasCost, tokenGasCost, opStackL1GasCost, + gasPrice, }; } ) @@ -103,12 +107,23 @@ const handler = async ( Object.keys(chainIdsWithToken).map((chainId, i) => [ chainId, { - gasPrice: gasPrices[i].maxFeePerGas.toString(), + gasPrice: + Number(chainId) === CHAIN_IDs.LINEA + ? gasCosts[i].gasPrice.toString() + : gasPrices[i].maxFeePerGas.toString(), gasPriceComponents: { - maxFeePerGas: gasPrices[i].maxFeePerGas - .sub(gasPrices[i].maxPriorityFeePerGas) - .toString(), - priorityFeePerGas: gasPrices[i].maxPriorityFeePerGas.toString(), + // Linea hardcodes base fee at 7 wei so we can always back it out fromthe gasPrice returned by the + // getGasCosts method. + maxFeePerGas: + Number(chainId) === CHAIN_IDs.LINEA + ? gasCosts[i].gasPrice.sub(7).toString() + : gasPrices[i].maxFeePerGas + .sub(gasPrices[i].maxPriorityFeePerGas) + .toString(), + priorityFeePerGas: + Number(chainId) === CHAIN_IDs.LINEA + ? "7" + : gasPrices[i].maxPriorityFeePerGas.toString(), baseFeeMultiplier: ethers.utils.formatEther( getGasMarkup(chainId).baseFeeMarkup ), @@ -118,7 +133,9 @@ const handler = async ( opStackL1GasCostMultiplier: sdk.utils.chainIsOPStack( Number(chainId) ) - ? ethers.utils.formatEther(getGasMarkup(chainId).baseFeeMarkup) + ? ethers.utils.formatEther( + getGasMarkup(chainId).opStackL1DataFeeMarkup + ) : undefined, }, nativeGasCost: gasCosts[i].nativeGasCost.toString(),