Skip to content

Commit

Permalink
fix: gas fee percent (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki authored and nicholaspai committed Feb 22, 2024
1 parent b31d77e commit 0182fa4
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/relayFeeCalculator/relayFeeCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,14 @@ export class RelayFeeCalculator {
throw new Error(`Could not find token information for ${inputToken}`);
}

if (simulateZeroFill) {
amountToRelay = safeOutputAmount;
// Reduce the output amount to simulate a full fill with a lower value to estimate
// the fill cost accurately without risking a failure due to insufficient balance.
deposit = isV2Deposit(deposit)
? { ...deposit, amount: amountToRelay }
: { ...deposit, outputAmount: amountToRelay };
}
const getGasCosts = this.queries.getGasCosts(deposit, amountToRelay, relayerAddress).catch((error) => {
// Reduce the output amount to simulate a full fill with a lower value to estimate
// the fill cost accurately without risking a failure due to insufficient balance.
const simulatedAmount = simulateZeroFill ? safeOutputAmount : toBN(amountToRelay);
deposit = isV2Deposit(deposit)
? { ...deposit, amount: simulatedAmount }
: { ...deposit, outputAmount: simulatedAmount };

const getGasCosts = this.queries.getGasCosts(deposit, simulatedAmount, relayerAddress).catch((error) => {
this.logger.error({
at: "sdk-v2/gasFeePercent",
message: "Error while fetching gas costs",
Expand Down

0 comments on commit 0182fa4

Please sign in to comment.