{"action":"created","comment":{"url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/comments/234530877","pull_request_review_id":176187947,"id":234530877,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDUzMDg3Nw==","diff_hunk":"@@ -119,14 +118,68 @@ const Pair = types.model({\n \n export interface IPair extends Instance<typeof Pair> {}\n \n+\n+const Price = types.model({\n+  price: types.number,\n+  symbol: types.string,\n+})\n+\n+export interface IPrice extends Instance<typeof Price> {}\n+\n export const Store = types.model({\n   pairSelected: types.reference(Pair),\n   pairs: types.array(Pair),\n+  prices: types.array(Price),\n })\n .actions(self => ({\n   selectPair(pair: IPair) {\n     self.pairSelected = cast(pair.id)\n   },\n+  fetchPrices: flow(function* fetchPrices() {\n+    try {\n+      const prices: [IPrice] = yield http.get(\n+        `${env.REACT_APP_API_HOST}/swap/prices`,\n+      )\n+      self.prices = cast(prices.map(price => ({ symbol: price.symbol, price: Number(price.price) })))\n+    } catch (error) {\n+      // tslint:disable-next-line:no-console\n+      console.error(`Failed to fetch prices`, error)\n+    }\n+  }),\n+  getTokenPriceInUsd(amount: number, denom: string) {\n+    const pricesData = self.prices\n+\n+    if (!pricesData) {\n+      return 0\n+    }\n+\n+    let BTCtoUSDT\n+    let denomToBTC\n+\n+    if (denom === 'USDT') {\n+      return 1\n+    }\n+\n+    for (const price of pricesData) {\n+      if (price.symbol === `${denom}USDT`) {\n+        return amount * price.price\n+      }\n+\n+      if (price.symbol === `${denom}BTC`) {\n+        denomToBTC = price.price\n+      }\n+\n+      if (price.symbol === 'BTCUSDT') {\n+        BTCtoUSDT = price.price\n+      }\n+    }\n+\n+    if (BTCtoUSDT && denomToBTC) {\n+      return amount * denomToBTC * BTCtoUSDT\n+    }\n+\n+    return 0","path":"gui/src/store/Store.ts","position":72,"original_position":72,"commit_id":"b5695f33076980f0d231f974ccdcf42b7ebc5189","original_commit_id":"b5695f33076980f0d231f974ccdcf42b7ebc5189","user":{"login":"codeclimate[bot]","id":36754821,"node_id":"MDM6Qm90MzY3NTQ4MjE=","avatar_url":"https://avatars0.githubusercontent.com/in/9403?v=4","gravatar_id":"","url":"https://api.github.com/users/codeclimate%5Bbot%5D","html_url":"https://github.com/apps/codeclimate","followers_url":"https://api.github.com/users/codeclimate%5Bbot%5D/followers","following_url":"https://api.github.com/users/codeclimate%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codeclimate%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codeclimate%5Bbot%5D/repos","events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"Avoid too many `return` statements within this function.","created_at":"2018-11-19T08:43:56Z","updated_at":"2018-11-19T08:43:56Z","html_url":"https://github.com/thorchain/ASGARDEX/pull/4#discussion_r234530877","pull_request_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/comments/234530877"},"html":{"href":"https://github.com/thorchain/ASGARDEX/pull/4#discussion_r234530877"},"pull_request":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4","id":231891706,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxODkxNzA2","html_url":"https://github.com/thorchain/ASGARDEX/pull/4","diff_url":"https://github.com/thorchain/ASGARDEX/pull/4.diff","patch_url":"https://github.com/thorchain/ASGARDEX/pull/4.patch","issue_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/4","number":4,"state":"open","locked":false,"title":"Haneef/token swap","user":{"login":"haneefghanim","id":2229766,"node_id":"MDQ6VXNlcjIyMjk3NjY=","avatar_url":"https://avatars1.githubusercontent.com/u/2229766?v=4","gravatar_id":"","url":"https://api.github.com/users/haneefghanim","html_url":"https://github.com/haneefghanim","followers_url":"https://api.github.com/users/haneefghanim/followers","following_url":"https://api.github.com/users/haneefghanim/following{/other_user}","gists_url":"https://api.github.com/users/haneefghanim/gists{/gist_id}","starred_url":"https://api.github.com/users/haneefghanim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haneefghanim/subscriptions","organizations_url":"https://api.github.com/users/haneefghanim/orgs","repos_url":"https://api.github.com/users/haneefghanim/repos","events_url":"https://api.github.com/users/haneefghanim/events{/privacy}","received_events_url":"https://api.github.com/users/haneefghanim/received_events","type":"User","site_admin":false},"body":"Created Token Swap page.\r\n\r\nPulled in `react-router` for routing. Using Binance API to pull in dynamic prices from token -> USDT. Still need to pull in real wallet info as well as token -> token exchange rates from CLPs. Right now we have only one CLP running for XLM, will need to add all the ones in the `helpers/tokens.ts` file.","created_at":"2018-11-19T08:43:39Z","updated_at":"2018-11-19T08:43:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73b47ba76b97741845a9938f95c654c21a925a06","assignee":null,"assignees":[],"requested_reviewers":[{"login":"philipstanislaus","id":6912756,"node_id":"MDQ6VXNlcjY5MTI3NTY=","avatar_url":"https://avatars1.githubusercontent.com/u/6912756?v=4","gravatar_id":"","url":"https://api.github.com/users/philipstanislaus","html_url":"https://github.com/philipstanislaus","followers_url":"https://api.github.com/users/philipstanislaus/followers","following_url":"https://api.github.com/users/philipstanislaus/following{/other_user}","gists_url":"https://api.github.com/users/philipstanislaus/gists{/gist_id}","starred_url":"https://api.github.com/users/philipstanislaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipstanislaus/subscriptions","organizations_url":"https://api.github.com/users/philipstanislaus/orgs","repos_url":"https://api.github.com/users/philipstanislaus/repos","events_url":"https://api.github.com/users/philipstanislaus/events{/privacy}","received_events_url":"https://api.github.com/users/philipstanislaus/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4/commits","review_comments_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4/comments","review_comment_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/4/comments","statuses_url":"https://api.github.com/repos/thorchain/ASGARDEX/statuses/b5695f33076980f0d231f974ccdcf42b7ebc5189","head":{"label":"thorchain:haneef/token-swap","ref":"haneef/token-swap","sha":"b5695f33076980f0d231f974ccdcf42b7ebc5189","user":{"login":"thorchain","id":40639099,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjM5MDk5","avatar_url":"https://avatars3.githubusercontent.com/u/40639099?v=4","gravatar_id":"","url":"https://api.github.com/users/thorchain","html_url":"https://github.com/thorchain","followers_url":"https://api.github.com/users/thorchain/followers","following_url":"https://api.github.com/users/thorchain/following{/other_user}","gists_url":"https://api.github.com/users/thorchain/gists{/gist_id}","starred_url":"https://api.github.com/users/thorchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorchain/subscriptions","organizations_url":"https://api.github.com/users/thorchain/orgs","repos_url":"https://api.github.com/users/thorchain/repos","events_url":"https://api.github.com/users/thorchain/events{/privacy}","received_events_url":"https://api.github.com/users/thorchain/received_events","type":"Organization","site_admin":false},"repo":{"id":142645084,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI2NDUwODQ=","name":"ASGARDEX","full_name":"thorchain/ASGARDEX","private":false,"owner":{"login":"thorchain","id":40639099,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjM5MDk5","avatar_url":"https://avatars3.githubusercontent.com/u/40639099?v=4","gravatar_id":"","url":"https://api.github.com/users/thorchain","html_url":"https://github.com/thorchain","followers_url":"https://api.github.com/users/thorchain/followers","following_url":"https://api.github.com/users/thorchain/following{/other_user}","gists_url":"https://api.github.com/users/thorchain/gists{/gist_id}","starred_url":"https://api.github.com/users/thorchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorchain/subscriptions","organizations_url":"https://api.github.com/users/thorchain/orgs","repos_url":"https://api.github.com/users/thorchain/repos","events_url":"https://api.github.com/users/thorchain/events{/privacy}","received_events_url":"https://api.github.com/users/thorchain/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/thorchain/ASGARDEX","description":"A fast and secure decentralised exchange built for THORChain","fork":false,"url":"https://api.github.com/repos/thorchain/ASGARDEX","forks_url":"https://api.github.com/repos/thorchain/ASGARDEX/forks","keys_url":"https://api.github.com/repos/thorchain/ASGARDEX/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thorchain/ASGARDEX/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thorchain/ASGARDEX/teams","hooks_url":"https://api.github.com/repos/thorchain/ASGARDEX/hooks","issue_events_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/events{/number}","events_url":"https://api.github.com/repos/thorchain/ASGARDEX/events","assignees_url":"https://api.github.com/repos/thorchain/ASGARDEX/assignees{/user}","branches_url":"https://api.github.com/repos/thorchain/ASGARDEX/branches{/branch}","tags_url":"https://api.github.com/repos/thorchain/ASGARDEX/tags","blobs_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/refs{/sha}","trees_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thorchain/ASGARDEX/statuses/{sha}","languages_url":"https://api.github.com/repos/thorchain/ASGARDEX/languages","stargazers_url":"https://api.github.com/repos/thorchain/ASGARDEX/stargazers","contributors_url":"https://api.github.com/repos/thorchain/ASGARDEX/contributors","subscribers_url":"https://api.github.com/repos/thorchain/ASGARDEX/subscribers","subscription_url":"https://api.github.com/repos/thorchain/ASGARDEX/subscription","commits_url":"https://api.github.com/repos/thorchain/ASGARDEX/commits{/sha}","git_commits_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/commits{/sha}","comments_url":"https://api.github.com/repos/thorchain/ASGARDEX/comments{/number}","issue_comment_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/comments{/number}","contents_url":"https://api.github.com/repos/thorchain/ASGARDEX/contents/{+path}","compare_url":"https://api.github.com/repos/thorchain/ASGARDEX/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thorchain/ASGARDEX/merges","archive_url":"https://api.github.com/repos/thorchain/ASGARDEX/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thorchain/ASGARDEX/downloads","issues_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues{/number}","pulls_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls{/number}","milestones_url":"https://api.github.com/repos/thorchain/ASGARDEX/milestones{/number}","notifications_url":"https://api.github.com/repos/thorchain/ASGARDEX/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thorchain/ASGARDEX/labels{/name}","releases_url":"https://api.github.com/repos/thorchain/ASGARDEX/releases{/id}","deployments_url":"https://api.github.com/repos/thorchain/ASGARDEX/deployments","created_at":"2018-07-28T03:57:28Z","updated_at":"2018-11-18T13:31:29Z","pushed_at":"2018-11-19T08:43:40Z","git_url":"git://github.com/thorchain/ASGARDEX.git","ssh_url":"git@github.com:thorchain/ASGARDEX.git","clone_url":"https://github.com/thorchain/ASGARDEX.git","svn_url":"https://github.com/thorchain/ASGARDEX","homepage":"https://asgard.exchange","size":1061,"stargazers_count":2,"watchers_count":2,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"thorchain:master","ref":"master","sha":"a37f77e7f63111ff1b4399a9e6fd5a1328a8707e","user":{"login":"thorchain","id":40639099,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjM5MDk5","avatar_url":"https://avatars3.githubusercontent.com/u/40639099?v=4","gravatar_id":"","url":"https://api.github.com/users/thorchain","html_url":"https://github.com/thorchain","followers_url":"https://api.github.com/users/thorchain/followers","following_url":"https://api.github.com/users/thorchain/following{/other_user}","gists_url":"https://api.github.com/users/thorchain/gists{/gist_id}","starred_url":"https://api.github.com/users/thorchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorchain/subscriptions","organizations_url":"https://api.github.com/users/thorchain/orgs","repos_url":"https://api.github.com/users/thorchain/repos","events_url":"https://api.github.com/users/thorchain/events{/privacy}","received_events_url":"https://api.github.com/users/thorchain/received_events","type":"Organization","site_admin":false},"repo":{"id":142645084,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI2NDUwODQ=","name":"ASGARDEX","full_name":"thorchain/ASGARDEX","private":false,"owner":{"login":"thorchain","id":40639099,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjM5MDk5","avatar_url":"https://avatars3.githubusercontent.com/u/40639099?v=4","gravatar_id":"","url":"https://api.github.com/users/thorchain","html_url":"https://github.com/thorchain","followers_url":"https://api.github.com/users/thorchain/followers","following_url":"https://api.github.com/users/thorchain/following{/other_user}","gists_url":"https://api.github.com/users/thorchain/gists{/gist_id}","starred_url":"https://api.github.com/users/thorchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorchain/subscriptions","organizations_url":"https://api.github.com/users/thorchain/orgs","repos_url":"https://api.github.com/users/thorchain/repos","events_url":"https://api.github.com/users/thorchain/events{/privacy}","received_events_url":"https://api.github.com/users/thorchain/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/thorchain/ASGARDEX","description":"A fast and secure decentralised exchange built for THORChain","fork":false,"url":"https://api.github.com/repos/thorchain/ASGARDEX","forks_url":"https://api.github.com/repos/thorchain/ASGARDEX/forks","keys_url":"https://api.github.com/repos/thorchain/ASGARDEX/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thorchain/ASGARDEX/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thorchain/ASGARDEX/teams","hooks_url":"https://api.github.com/repos/thorchain/ASGARDEX/hooks","issue_events_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/events{/number}","events_url":"https://api.github.com/repos/thorchain/ASGARDEX/events","assignees_url":"https://api.github.com/repos/thorchain/ASGARDEX/assignees{/user}","branches_url":"https://api.github.com/repos/thorchain/ASGARDEX/branches{/branch}","tags_url":"https://api.github.com/repos/thorchain/ASGARDEX/tags","blobs_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/refs{/sha}","trees_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thorchain/ASGARDEX/statuses/{sha}","languages_url":"https://api.github.com/repos/thorchain/ASGARDEX/languages","stargazers_url":"https://api.github.com/repos/thorchain/ASGARDEX/stargazers","contributors_url":"https://api.github.com/repos/thorchain/ASGARDEX/contributors","subscribers_url":"https://api.github.com/repos/thorchain/ASGARDEX/subscribers","subscription_url":"https://api.github.com/repos/thorchain/ASGARDEX/subscription","commits_url":"https://api.github.com/repos/thorchain/ASGARDEX/commits{/sha}","git_commits_url":"https://api.github.com/repos/thorchain/ASGARDEX/git/commits{/sha}","comments_url":"https://api.github.com/repos/thorchain/ASGARDEX/comments{/number}","issue_comment_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues/comments{/number}","contents_url":"https://api.github.com/repos/thorchain/ASGARDEX/contents/{+path}","compare_url":"https://api.github.com/repos/thorchain/ASGARDEX/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thorchain/ASGARDEX/merges","archive_url":"https://api.github.com/repos/thorchain/ASGARDEX/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thorchain/ASGARDEX/downloads","issues_url":"https://api.github.com/repos/thorchain/ASGARDEX/issues{/number}","pulls_url":"https://api.github.com/repos/thorchain/ASGARDEX/pulls{/number}","milestones_url":"https://api.github.com/repos/thorchain/ASGARDEX/milestones{/number}","notifications_url":"https://api.github.com/repos/thorchain/ASGARDEX/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thorchain/ASGARDEX/labels{/name}","releases_url":"https://api.github.com/repos/thorchain/ASGARDEX/releases{/id}","deployments_url":"https://api.github.com/repos/thorchain/ASGARDEX/deployments","created_at":"2018-07-28T03:57:28Z","updated_at":"2018-11-18T13:31:29Z","pushed_at":"2018-11-19T08:43:40Z","git_url":"git://github.com/thorchain/ASGARDEX.git","ssh_url":"git@github.com:thorchain/ASGARDEX.git","clone_url":"https://github.com/thorchain/ASGARDEX.git","svn_url":"https://github.com/thorchain/ASGARDEX","homepage":"https://asgard.exchange","size":1061,"stargazers_count":2,"watchers_count":2,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4"},"html":{"href":"https://github.com/thorchain/ASGARDEX/pull/4"},"issue":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/issues/4"},"comments":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/thorchain/ASGARDEX/statuses/b5695f33076980f0d231f974ccdcf42b7ebc5189"}},"author_association":"NONE"}}
{"actor":{"display_login":"codeclimate"}}