Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Sep 6, 2024
1 parent 279efc3 commit 8af4b05
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 5 additions & 3 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@ export const getRelayerFeeDetails = async (
originChainId: number;
destinationChainId: number;
recipientAddress: string;
message?: string;
relayerAddress?: string;
},
tokenPrice?: number,
message?: string,
relayerAddress?: string,
gasPrice?: sdk.utils.BigNumberish,
gasUnits?: sdk.utils.BigNumberish
): Promise<sdk.relayFeeCalculator.RelayerFeeDetails> => {
Expand All @@ -627,6 +627,8 @@ export const getRelayerFeeDetails = async (
originChainId,
destinationChainId,
recipientAddress,
message,
relayerAddress,
} = deposit;
const relayFeeCalculator = getRelayerFeeCalculator(destinationChainId, {
relayerAddress,
Expand All @@ -646,7 +648,7 @@ export const getRelayerFeeDetails = async (
sdk.utils.isMessageEmpty(message),
relayerAddress,
tokenPrice,
gasPrice, // FIXME: We need properly cache the gas price before this can be used reliably
gasPrice,
gasUnits
);
} catch (err: unknown) {
Expand Down
18 changes: 6 additions & 12 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,19 @@ const handler = async (
},
];

const relayerAddress = getDefaultRelayerAddress(
destinationChainId,
l1Token.symbol
);
const depositArgs = {
amount: ethers.BigNumber.from("10").pow(l1Token.decimals),
inputToken: inputToken.address,
outputToken: outputToken.address,
recipientAddress: DEFAULT_SIMULATED_RECIPIENT_ADDRESS,
originChainId: computedOriginChainId,
destinationChainId,
relayerAddress,
};
const relayerAddress = getDefaultRelayerAddress(
destinationChainId,
l1Token.symbol
);

const [tokenPriceNative, _tokenPriceUsd, latestBlock, gasPrice, gasUnits] =
await Promise.all([
Expand All @@ -147,14 +148,7 @@ const handler = async (
transferRestrictedBalances,
fullRelayerMainnetBalances,
] = await Promise.all([
getRelayerFeeDetails(
depositArgs,
tokenPriceNative,
undefined,
getDefaultRelayerAddress(destinationChainId, l1Token.symbol),
gasPrice,
gasUnits
),
getRelayerFeeDetails(depositArgs, tokenPriceNative, gasPrice, gasUnits),
callViaMulticall3(provider, multiCalls, {
blockTag: latestBlock.number,
}),
Expand Down
13 changes: 9 additions & 4 deletions api/suggested-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ const handler = async (
recipientAddress: recipient,
originChainId: computedOriginChainId,
destinationChainId,
message,
relayerAddress: relayer,
};

const [
Expand All @@ -221,6 +223,7 @@ const handler = async (
tokenPriceUsd,
limits,
gasPrice,
gasUnits,
] = await Promise.all([
callViaMulticall3(provider, multiCalls, { blockTag: quoteBlockNumber }),
getCachedTokenPrice(l1Token.address, baseCurrency),
Expand All @@ -232,7 +235,10 @@ const handler = async (
destinationChainId
),
getCachedGasPrice(destinationChainId),
getCachedFillGasUsage(depositArgs, { relayerAddress: relayer }),
// Only use cached fill gas usage if message is empty
sdk.utils.isMessageEmpty(message)
? undefined
: getCachedFillGasUsage(depositArgs, { relayerAddress: relayer }),
]);
const quoteTimestamp = parseInt(_quoteTimestamp.toString());

Expand Down Expand Up @@ -266,9 +272,8 @@ const handler = async (
const relayerFeeDetails = await getRelayerFeeDetails(
depositArgs,
tokenPrice,
message,
relayer,
gasPrice
gasPrice,
gasUnits
);

const skipAmountLimitEnabled = skipAmountLimit === "true";
Expand Down

0 comments on commit 8af4b05

Please sign in to comment.