mirror of
https://github.com/tornadocash/tornado-pool-relayer
synced 2024-02-02 15:04:09 +01:00
fix: gas price
This commit is contained in:
parent
83520bc61a
commit
f8f33e0b39
@ -11,7 +11,7 @@ export const RPC_LIST: { [chainId in ChainId]: string } = {
|
||||
[ChainId.MAINNET]: 'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5',
|
||||
[ChainId.GOERLI]: 'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh',
|
||||
[ChainId.OPTIMISM]: 'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8',
|
||||
[ChainId.XDAI]: 'https://xdai-rpc.ztake.org',
|
||||
[ChainId.XDAI]: 'https://rpc.xdaichain.com/tornado',
|
||||
};
|
||||
|
||||
export const OFF_CHAIN_ORACLE = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';
|
||||
|
@ -7,6 +7,16 @@ import { GasPriceOracle } from 'gas-price-oracle';
|
||||
import { toWei } from '@/utilities';
|
||||
import { RPC_LIST } from '@/constants';
|
||||
|
||||
const bump = (gas: BigNumber, percent: number) => gas.mul(percent).div(100).toHexString();
|
||||
const gweiToWei = (value: number) => toWei(String(value), 'gwei');
|
||||
|
||||
const percentBump = {
|
||||
INSTANT: 150,
|
||||
FAST: 130,
|
||||
STANDARD: 85,
|
||||
LOW: 50,
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class GasPriceService {
|
||||
private readonly chainId: number;
|
||||
@ -21,15 +31,13 @@ export class GasPriceService {
|
||||
defaultRpc: RPC_LIST[this.chainId],
|
||||
});
|
||||
|
||||
const fast = await instance.fetchGasPriceFromRpc();
|
||||
|
||||
const bnGas = BigNumber.from(toWei(String(fast), 'gwei'));
|
||||
const result = await instance.gasPrices();
|
||||
|
||||
return {
|
||||
instant: bnGas.mul(150).div(100).toHexString(),
|
||||
fast: bnGas.mul(130).div(100).toHexString(),
|
||||
standard: bnGas.mul(85).div(100).toHexString(),
|
||||
low: bnGas.mul(50).div(100).toHexString(),
|
||||
instant: bump(gweiToWei(result.instant), percentBump.INSTANT),
|
||||
fast: bump(gweiToWei(result.instant), percentBump.FAST),
|
||||
standard: bump(gweiToWei(result.standard), percentBump.STANDARD),
|
||||
low: bump(gweiToWei(result.low), percentBump.LOW),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user