Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gas fee percent #572

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@across-protocol/sdk-v2",
"author": "UMA Team",
"version": "0.22.4",
"version": "0.22.5",
"license": "AGPL-3.0",
"homepage": "https://docs.across.to/v/developer-docs/developers/across-sdk",
"files": [
Expand Down
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
Loading