public async Task <BigInteger> CalculateGasPriceAsync(string to, BigInteger amount) { var estimatedGasPrice = await _ethereum.EstimateGasPriceAsync(to, amount); var minMaxGasPrice = await _gasPriceRepository.TryGetAsync(); if (minMaxGasPrice == null) { minMaxGasPrice = new GasPriceEntity { Max = _defaultMaxGasPrice, Min = _defaultMinGasPrice }; await _gasPriceRepository.AddOrReplaceAsync(minMaxGasPrice); } if (estimatedGasPrice <= minMaxGasPrice.Min) { return(minMaxGasPrice.Min); } if (estimatedGasPrice >= minMaxGasPrice.Max) { return(minMaxGasPrice.Max); } return(estimatedGasPrice); }