Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Update the prefix of forex #2687

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/app/src/queries/rates/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { AssetTypes } from './types'

export const COMMODITIES_BASE_API_URL =
'https://forex-data-feed.swissquote.com/public-quotes/bboquotes/instrument'

export const FOREX_BASE_API_URL = 'https://api.exchangerate.host/latest'

export const DEFAULT_PYTH_TV_ENDPOINT =
'https://benchmarks.pyth.network/v1/shims/tradingview/history'

export const NON_CRYPTO_ASSET_TYPES: AssetTypes = {
Metal: ['XAU', 'XAG'],
FX: ['EUR', 'GBP', 'AUD'],
}
2 changes: 2 additions & 0 deletions packages/app/src/queries/rates/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export type PythResponse = {
v: number[]
s: string
}

export type AssetTypes = Record<string, string[]>
9 changes: 6 additions & 3 deletions packages/app/src/queries/rates/useCandlesticksQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { DEFAULT_NETWORK_ID } from 'constants/defaults'
import logError from 'utils/logError'

import { DEFAULT_PYTH_TV_ENDPOINT } from './constants'
import { DEFAULT_PYTH_TV_ENDPOINT, NON_CRYPTO_ASSET_TYPES } from './constants'
import { mapCandles, mapPythCandles } from './utils'

export const requestCandlesticks = async (
Expand All @@ -18,8 +18,11 @@
) => {
const ratesEndpoint = getRatesEndpoint(networkId)
const pythTvEndpoint = DEFAULT_PYTH_TV_ENDPOINT
const metalAssets = ['XAU', 'XAG']
const prefix = metalAssets.includes(currencyKey!) ? 'Metal' : 'Crypto'

let prefix =
Object.keys(NON_CRYPTO_ASSET_TYPES).find((type) =>
NON_CRYPTO_ASSET_TYPES[type].includes(currencyKey!)
) || 'Crypto'

Check warning on line 25 in packages/app/src/queries/rates/useCandlesticksQuery.ts

View check run for this annotation

Codecov / codecov/patch

packages/app/src/queries/rates/useCandlesticksQuery.ts#L24-L25

Added lines #L24 - L25 were not covered by tests

if (period <= 3600) {
const response = await axios
Expand Down
Loading