Fallback gas prices for light mode
This commit is contained in:
parent
1a375d1cd9
commit
fecac18687
@ -31,3 +31,60 @@ export const tornToken = {
|
||||
symbol: 'TORN',
|
||||
decimals: 18,
|
||||
};
|
||||
|
||||
export const networkConfig = {
|
||||
netId56: {
|
||||
gasPrices: {
|
||||
instant: 5,
|
||||
fast: 5,
|
||||
standard: 5,
|
||||
low: 5,
|
||||
},
|
||||
nativeCurrency: 'bnb',
|
||||
},
|
||||
netId10: {
|
||||
gasPrices: {
|
||||
instant: 0.001,
|
||||
fast: 0.001,
|
||||
standard: 0.001,
|
||||
low: 0.001,
|
||||
},
|
||||
nativeCurrency: 'eth',
|
||||
},
|
||||
netId100: {
|
||||
gasPrices: {
|
||||
instant: 6,
|
||||
fast: 5,
|
||||
standard: 4,
|
||||
low: 1,
|
||||
},
|
||||
nativeCurrency: 'xdai',
|
||||
},
|
||||
netId137: {
|
||||
gasPrices: {
|
||||
instant: 100,
|
||||
fast: 75,
|
||||
standard: 50,
|
||||
low: 30,
|
||||
},
|
||||
nativeCurrency: 'matic',
|
||||
},
|
||||
netId42161: {
|
||||
gasPrices: {
|
||||
instant: 4,
|
||||
fast: 3,
|
||||
standard: 2.52,
|
||||
low: 2.29,
|
||||
},
|
||||
nativeCurrency: 'eth',
|
||||
},
|
||||
netId43114: {
|
||||
gasPrices: {
|
||||
instant: 225,
|
||||
fast: 35,
|
||||
standard: 25,
|
||||
low: 25,
|
||||
},
|
||||
nativeCurrency: 'avax',
|
||||
},
|
||||
};
|
||||
|
@ -12,12 +12,10 @@ export const relayerProcessor: RelayerProcessor = async (job) => {
|
||||
const withdrawalData = job.data;
|
||||
await txService.checkTornadoFee(withdrawalData);
|
||||
const txData = await txService.prepareTxData(withdrawalData);
|
||||
const receipt = await txService.sendTx(txData);
|
||||
return receipt;
|
||||
return await txService.sendTx(txData);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
await job.update({ ...job.data, status: JobStatus.FAILED });
|
||||
throw new Error(e.message);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,4 +1,14 @@
|
||||
import { instances, minimumBalance, netId, privateKey, rpcUrl, torn, tornadoGoerliProxy, tornToken } from '../config';
|
||||
import {
|
||||
instances,
|
||||
minimumBalance,
|
||||
netId,
|
||||
networkConfig,
|
||||
privateKey,
|
||||
rpcUrl,
|
||||
torn,
|
||||
tornadoGoerliProxy,
|
||||
tornToken,
|
||||
} from '../config';
|
||||
import { Token } from '../types';
|
||||
import { getProvider, getTornadoProxyContract, getTornadoProxyLightContract } from '../modules/contracts';
|
||||
import { resolve } from '../modules';
|
||||
@ -7,6 +17,7 @@ import { availableIds, netIds, NetInstances } from '../../../torn-token';
|
||||
import { getAddress } from 'ethers/lib/utils';
|
||||
import { providers, Wallet } from 'ethers';
|
||||
import { container, singleton } from 'tsyringe';
|
||||
import { GasPrice } from 'gas-price-oracle/lib/types';
|
||||
|
||||
type relayerQueueName = `relayer_${availableIds}`
|
||||
|
||||
@ -26,6 +37,9 @@ export class ConfigService {
|
||||
public readonly privateKey = privateKey;
|
||||
public readonly rpcUrl = rpcUrl;
|
||||
isInit: boolean;
|
||||
nativeCurrency: string;
|
||||
fallbackGasPrices: GasPrice;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.netIdKey = `netId${this.netId}`;
|
||||
@ -74,6 +88,9 @@ export class ConfigService {
|
||||
if (this.isLightMode) {
|
||||
this._proxyAddress = await resolve(torn.tornadoProxyLight.address);
|
||||
this._proxyContract = getTornadoProxyLightContract(this._proxyAddress);
|
||||
const { gasPrices, nativeCurrency } = networkConfig[this.netIdKey];
|
||||
this.nativeCurrency = nativeCurrency;
|
||||
this.fallbackGasPrices = gasPrices;
|
||||
} else {
|
||||
this._proxyAddress = tornadoGoerliProxy;
|
||||
if (this.netId === 1) {
|
||||
@ -92,6 +109,7 @@ export class ConfigService {
|
||||
console.log(
|
||||
`Configuration completed\n-- netId: ${this.netId}\n-- rpcUrl: ${this.rpcUrl}`);
|
||||
this.isInit = true;
|
||||
console.log(this);
|
||||
} catch (e) {
|
||||
console.error(`${this.constructor.name} Error:`, e.message);
|
||||
}
|
||||
|
@ -42,7 +42,11 @@ export class TxService {
|
||||
this.txManager = new TxManager({ privateKey, rpcUrl, config: { THROW_ON_REVERT: true } });
|
||||
this.tornadoProxy = this.config.proxyContract;
|
||||
this.provider = this.tornadoProxy.provider;
|
||||
this.oracle = new GasPriceOracle({ defaultRpc: rpcUrl, chainId: netId });
|
||||
this.oracle = new GasPriceOracle({
|
||||
defaultRpc: rpcUrl,
|
||||
chainId: netId,
|
||||
defaultFallbackGasPrices: this.config?.fallbackGasPrices,
|
||||
});
|
||||
}
|
||||
|
||||
async updateJobData(data: Partial<RelayerJobData>) {
|
||||
@ -57,15 +61,15 @@ export class TxService {
|
||||
|
||||
const receipt = await currentTx.send()
|
||||
.on('transactionHash', async txHash => {
|
||||
console.log({ txHash });
|
||||
console.log('Transaction sent, txHash: ', txHash);
|
||||
await this.updateJobData({ txHash, status: JobStatus.SENT });
|
||||
})
|
||||
.on('mined', async receipt => {
|
||||
console.log('Mined in block', receipt.blockNumber);
|
||||
console.log('Transaction mined in block', receipt.blockNumber);
|
||||
await this.updateJobData({ status: JobStatus.MINED });
|
||||
})
|
||||
.on('confirmations', async confirmations => {
|
||||
console.log({ confirmations });
|
||||
console.log('Transaction confirmations: ', confirmations);
|
||||
await this.updateJobData({ confirmations });
|
||||
});
|
||||
if (receipt.status === 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user