Bump gas limit for any transaction type in V4 fee oracle, if bump percent provided & change lib version to 1.3.1
This commit is contained in:
parent
a0476b0e34
commit
42b57f8734
@ -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",
|
||||
|
@ -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<number> {
|
||||
if (type === 'user_withdrawal') return BigNumber.from(defaultWithdrawalGasLimit[this.chainId]).toNumber();
|
||||
async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent: number = 0): Promise<number> {
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user