Skip to content

Commit

Permalink
Merge branch 'gas-price-relayer-fee-details' into 3.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Jan 9, 2025
2 parents 6807fc0 + 5cdec88 commit ace32f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 2 additions & 0 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,7 @@ export function isContractCache(chainId: number, address: string) {

export function getCachedFillGasUsage(
deposit: Parameters<typeof buildDepositForSimulation>[0],
gasPrice: BigNumber,
overrides?: Partial<{
spokePoolAddress: string;
relayerAddress: string;
Expand Down Expand Up @@ -2022,6 +2023,7 @@ export function getCachedFillGasUsage(
buildDepositForSimulation(deposit),
overrides?.relayerAddress,
{
gasPrice,
// Scale the op stack L1 gas cost component by the base fee multiplier.
// Consider adding a new environment variable OP_STACK_L1_GAS_COST_MARKUP if we want finer-grained control.
opStackL1GasCostMultiplier: getGasMarkup(
Expand Down
33 changes: 17 additions & 16 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,39 +164,30 @@ const handler = async (
message,
};

const [tokenPriceNative, _tokenPriceUsd, latestBlock, gasCosts, gasPrice] =
const [tokenPriceNative, _tokenPriceUsd, latestBlock, gasPrice] =
await Promise.all([
getCachedTokenPrice(
l1Token.address,
sdk.utils.getNativeTokenSymbol(destinationChainId).toLowerCase()
),
getCachedTokenPrice(l1Token.address, "usd"),
getCachedLatestBlock(HUB_POOL_CHAIN_ID),
// Only use cached gas units if message is not defined, i.e. standard for standard bridges
isMessageDefined
? undefined
: getCachedFillGasUsage(depositArgs, {
relayerAddress: relayer,
}),
latestGasPriceCache(destinationChainId, computedOriginChainId).get(),
]);
const tokenPriceUsd = ethers.utils.parseUnits(_tokenPriceUsd.toString());

const [
relayerFeeDetails,
gasCosts,
multicallOutput,
fullRelayerBalances,
transferRestrictedBalances,
fullRelayerMainnetBalances,
] = await Promise.all([
getRelayerFeeDetails(
depositArgs,
tokenPriceNative,
relayer,
gasPrice,
gasCosts?.nativeGasCost,
gasCosts?.tokenGasCost
),
isMessageDefined
? undefined // Only use cached gas units if message is not defined, i.e. standard for standard bridges
: getCachedFillGasUsage(depositArgs, gasPrice, {
relayerAddress: relayer,
}),
callViaMulticall3(provider, multiCalls, {
blockTag: latestBlock.number,
}),
Expand Down Expand Up @@ -226,6 +217,16 @@ const handler = async (
)
),
]);
// This call should not make any additional RPC queries if gasCosts is defined--for any deposit
// with an empty message.
const relayerFeeDetails = await getRelayerFeeDetails(
depositArgs,
tokenPriceNative,
relayer,
gasPrice,
gasCosts?.nativeGasCost,
gasCosts?.tokenGasCost
);
logger.debug({
at: "Limits",
message: "Relayer fee details from SDK",
Expand Down

0 comments on commit ace32f2

Please sign in to comment.