Get USD value for token-value map

* get current USD value for an arbirary size token-value map
This commit is contained in:
Teemu Patja 2017-08-04 12:16:13 +03:00
parent f379da4924
commit 209698c170
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 9 additions and 0 deletions

View File

@ -12,3 +12,12 @@
(json/read-str))]
(-> (get-in m ["ticker" "price"])
(read-string))))
(defn bounty-usd-value
"Get current USD value of a bounty. bounty is a map of token-name to value"
[bounty]
(reduce + (map (fn [[token value]]
(let [usd-price (get-token-usd-price token)]
(* usd-price value)))
bounty)))