def __init__(self, refresh_interval: int, expiry: int, ethgasstation_api_key=None, poa_network_alt_url=None, etherscan_api_key=None, gasnow_app_name="pygasprice-client"): self.clients = [ EthGasStation(refresh_interval=refresh_interval, expiry=expiry, api_key=ethgasstation_api_key), EtherchainOrg(refresh_interval=refresh_interval, expiry=expiry), POANetwork(refresh_interval=refresh_interval, expiry=expiry, alt_url=poa_network_alt_url), Etherscan(refresh_interval=refresh_interval, expiry=expiry, api_key=etherscan_api_key), Gasnow(refresh_interval=refresh_interval, expiry=expiry, app_name=gasnow_app_name) ] self._safe_low_price = None self._standard_price = None self._fast_price = None self._fastest_price = None super().__init__("aggregator", refresh_interval, expiry)
def __init__(self, arguments, web3: Web3): assert isinstance(web3, Web3) self.gas_station = None self.fixed_gas = None self.web3 = web3 if arguments.ethgasstation_api_key: self.gas_station = EthGasStation(refresh_interval=60, expiry=600, api_key=arguments.ethgasstation_api_key) elif arguments.etherchain_gas: self.gas_station = EtherchainOrg(refresh_interval=60, expiry=600) elif arguments.poanetwork_gas: self.gas_station = POANetwork(refresh_interval=60, expiry=600, alt_url=arguments.poanetwork_url) elif arguments.etherscan_gas: if arguments.etherscan_key: self.gas_station = Etherscan(refresh_interval=60, expiry=600, api_key=arguments.etherscan_key) else: self.gas_station = Etherscan(refresh_interval=60, expiry=600) elif arguments.gasnow_gas: if arguments.gasnow_app_name: self.gas_station = GasNow(refresh_interval=60, expiry=600, app_name=arguments.gasnow_app_name) else: self.gas_station = GasNow(refresh_interval=60, expiry=600) elif arguments.fixed_gas_price: self.fixed_gas = int(round(arguments.fixed_gas_price * self.GWEI)) self.initial_multiplier = arguments.gas_initial_multiplier self.reactive_multiplier = arguments.gas_reactive_multiplier self.gas_maximum = int(round(arguments.gas_maximum * self.GWEI)) if self.fixed_gas: assert self.fixed_gas <= self.gas_maximum
def __init__(self, refresh_interval: int, expiry: int, ethgasstation_api_key=None, poa_network_alt_url=None, etherscan_api_key=None, blocknative_api_key=None): self.clients = [ EthGasStation(refresh_interval=refresh_interval, expiry=expiry, api_key=ethgasstation_api_key), EtherchainOrg(refresh_interval=refresh_interval, expiry=expiry), POANetwork(refresh_interval=refresh_interval, expiry=expiry, alt_url=poa_network_alt_url), Etherscan(refresh_interval=refresh_interval, expiry=expiry, api_key=etherscan_api_key) ] if blocknative_api_key: self.clients.append(Blocknative(refresh_interval=refresh_interval, expiry=expiry, api_key=blocknative_api_key)) super().__init__("aggregator", refresh_interval, expiry)
def test_etherchain_integration(): logging.basicConfig(format='%(asctime)-15s %(levelname)-8s %(message)s', level=logging.DEBUG) logging.getLogger('urllib3.connectionpool').setLevel(logging.INFO) logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.INFO) etherchain = EtherchainOrg(10, 600) while True: safe_low_price = etherchain.safe_low_price() logging.info(safe_low_price) standard_price = etherchain.standard_price() logging.info(standard_price) fast_price = etherchain.fast_price() logging.info(fast_price) if safe_low_price is not None and standard_price is not None and fast_price is not None: break time.sleep(1)
def __init__(self, arguments): self.gas_station = None if arguments.ethgasstation_api_key: self.gas_station = EthGasStation( refresh_interval=60, expiry=600, api_key=arguments.ethgasstation_api_key) elif arguments.etherchain_gas: self.gas_station = EtherchainOrg(refresh_interval=60, expiry=600) elif arguments.poanetwork_gas: self.gas_station = POANetwork(refresh_interval=60, expiry=600, alt_url=arguments.poanetwork_url)
def __init__(self, arguments): self.gas_station = None self.fixed_gas = None if arguments.ethgasstation_api_key: self.gas_station = EthGasStation(refresh_interval=60, expiry=600, api_key=arguments.ethgasstation_api_key) elif arguments.etherchain_gas: self.gas_station = EtherchainOrg(refresh_interval=60, expiry=600) elif arguments.poanetwork_gas: self.gas_station = POANetwork(refresh_interval=60, expiry=600, alt_url=arguments.poanetwork_url) elif arguments.fixed_gas_price: self.fixed_gas = int(round(arguments.fixed_gas_price * self.GWEI)) self.initial_multiplier = arguments.gas_initial_multiplier self.reactive_multiplier = arguments.gas_reactive_multiplier self.gas_maximum = int(round(arguments.gas_maximum * self.GWEI)) if self.fixed_gas: assert self.fixed_gas <= self.gas_maximum