diff --git a/package.json b/package.json index a39f9ff..225e76a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tornado/tornado-oracles", - "version": "1.3.0", + "version": "1.3.1", "description": "Gas oracle for Tornado-specific transactions", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/feeOracleV4.ts b/src/feeOracleV4.ts index d46ab00..df21af4 100644 --- a/src/feeOracleV4.ts +++ b/src/feeOracleV4.ts @@ -2,7 +2,6 @@ import { defaultWithdrawalGasLimit } from './config'; import { TornadoFeeOracle } from './feeOracle'; import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPrices } from './types'; import { GasPriceOracle } from '@tornado/gas-price-oracle'; -import { BigNumber } from 'ethers'; import { bump } from './utils'; export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeOracle { @@ -17,8 +16,8 @@ export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeO super(chainId, rpcUrl, gasPriceOracle); } - async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent?: number): Promise { - if (type === 'user_withdrawal') return BigNumber.from(defaultWithdrawalGasLimit[this.chainId]).toNumber(); + async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent: number = 0): Promise { + if (type === 'user_withdrawal') return bump(defaultWithdrawalGasLimit[this.chainId], bumpPercent).toNumber(); // Need to bump relayer gas limit for transaction, because predefined gas limit to small to be 100% sure that transaction will be sent // This leads to fact that relayer often pays extra for gas from his own funds, however, this was designed by previous developers @@ -27,7 +26,7 @@ export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeO // For compatibility reasons, when wee check user-provided fee for V4 withdrawal transaction, we need dump gas limit // for about 20 percent,so that the transaction will be sent, even if it results in some loss for the relayer if (type === 'relayer_withdrawal_check_v4') return bump(defaultWithdrawalGasLimit[this.chainId], -25).toNumber(); - if (!tx) return 21_000; + if (!tx) return bump(21_000, bumpPercent).toNumber(); return (await this.provider.estimateGas(tx)).toNumber(); }