Use max(average,average_calc) when calculating gas price

This should protect against short-term gas price fluctuations
This commit is contained in:
Vitaliy Vlasov 2018-04-02 23:35:18 +03:00
parent 6f0596e09b
commit 56c067e5cf
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
1 changed files with 5 additions and 2 deletions

View File

@ -77,8 +77,11 @@
(defn eth-gasstation-gas-price
[]
(let [data (json-api-request "https://ethgasstation.info/json/ethgasAPI.json")
avg-price (-> (get data "average")
bigint)
avg-price (max
(-> (get data "average")
bigint)
(-> (get data "average_calc")
bigint))
avg-price-gwei (/ avg-price (bigint 10))]
(->> (* (bigint (Math/pow 10 9)) avg-price-gwei) ;; for some reason the API returns 10x gwei price
.toBigInteger)))