From f51d13080187cb74031cd7efe30e1ed1dae6272b Mon Sep 17 00:00:00 2001 From: Adam Clarke Date: Thu, 5 Jan 2023 17:43:37 +0000 Subject: [PATCH 1/4] Query open orders from contract instead of subgraph (#1833) --- sdk/services/futures.ts | 56 ++++++++++++++++++++++------------------- sdk/utils/futures.ts | 38 +++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/sdk/services/futures.ts b/sdk/services/futures.ts index 3ba500e030..f68d2ffedd 100644 --- a/sdk/services/futures.ts +++ b/sdk/services/futures.ts @@ -4,15 +4,16 @@ import { Contract as EthCallContract } from 'ethcall'; import { BigNumber, ContractTransaction, ethers } from 'ethers'; import { formatBytes32String, parseBytes32String } from 'ethers/lib/utils'; import request, { gql } from 'graphql-request'; +import { orderBy } from 'lodash'; import KwentaSDK from 'sdk'; import { DAY_PERIOD, KWENTA_TRACKING_CODE } from 'queries/futures/constants'; import { getFuturesAggregateStats } from 'queries/futures/subgraph'; -import { mapFuturesOrders } from 'queries/futures/utils'; import { UNSUPPORTED_NETWORK } from 'sdk/common/errors'; import { BPS_CONVERSION } from 'sdk/constants/futures'; import { Period, PERIOD_IN_SECONDS } from 'sdk/constants/period'; import { getContractsByNetwork } from 'sdk/contracts'; +import CrossMarginBaseABI from 'sdk/contracts/abis/CrossMarginBase.json'; import FuturesMarketABI from 'sdk/contracts/abis/FuturesMarket.json'; import FuturesMarketInternal from 'sdk/contracts/FuturesMarketInternal'; import { @@ -28,7 +29,6 @@ import { FuturesMarket, FuturesMarketAsset, FuturesMarketKey, - FuturesOrder, FuturesVolumes, MarketClosureReason, PositionDetail, @@ -41,6 +41,7 @@ import { getFuturesEndpoint, getMarketName, getReasonFromCode, + mapFuturesOrderFromEvent, mapFuturesPosition, marketsForNetwork, } from 'sdk/utils/futures'; @@ -384,33 +385,36 @@ export default class FuturesService { } public async getOpenOrders(account: string) { - const response = await request( - this.futuresGqlEndpoint, - gql` - query OpenOrders($account: String!) { - futuresOrders(where: { abstractAccount: $account, status: Pending }) { - id - account - size - market - asset - targetRoundId - marginDelta - targetPrice - timestamp - orderType + if (!this.sdk.context.signer) return []; + + const crossMarginBaseMultiCall = new EthCallContract(account, CrossMarginBaseABI); + const crossMarginBaseContract = CrossMarginBase__factory.connect( + account, + this.sdk.context.signer + ); + const accountFilter = crossMarginBaseContract.filters.OrderPlaced(account); + const orders = []; + + if (accountFilter) { + const logs = await crossMarginBaseContract.queryFilter(accountFilter); + if (logs.length) { + const orderCalls = logs.map((l) => crossMarginBaseMultiCall.orders(l.args.orderId)); + const contractOrders = (await this.sdk.context.multicallProvider.all(orderCalls)) as any; + for (let i = 0; i < logs.length; i++) { + const log = logs[i]; + const contractOrder = contractOrders[i]; + // Checks if the order is still pending + // Orders are never removed but all values set to zero so we check a zero value on price to filter pending + if (contractOrder && contractOrder.targetPrice.gt(0)) { + const block = await log.getBlock(); + const order = mapFuturesOrderFromEvent(log, account, wei(block.timestamp)); + orders.push(order); } } - `, - { account: account } - ); + } + } - const openOrders: FuturesOrder[] = response - ? response.futuresOrders.map((o: any) => { - return mapFuturesOrders(o); - }) - : []; - return openOrders; + return orderBy(orders, ['timestamp'], 'desc'); } public async getCrossMarginSettings() { diff --git a/sdk/utils/futures.ts b/sdk/utils/futures.ts index 4f294eb569..27f90072c3 100644 --- a/sdk/utils/futures.ts +++ b/sdk/utils/futures.ts @@ -1,14 +1,17 @@ import Wei, { wei } from '@synthetixio/wei'; import { BigNumber } from 'ethers'; +import { parseBytes32String } from 'ethers/lib/utils.js'; import { ETH_UNIT } from 'constants/network'; import { FuturesAggregateStatResult } from 'queries/futures/subgraph'; import { FUTURES_ENDPOINTS, MAINNET_MARKETS, TESTNET_MARKETS } from 'sdk/constants/futures'; import { SECONDS_PER_DAY } from 'sdk/constants/period'; +import { OrderPlacedEvent } from 'sdk/contracts/types/CrossMarginBase'; import { FundingRateUpdate, FuturesMarketAsset, FuturesMarketKey, + FuturesOrder, FuturesPosition, FuturesPotentialTradeDetails, FuturesVolumes, @@ -23,7 +26,8 @@ import { CrossMarginSettings, IsolatedMarginOrderType, } from 'state/futures/types'; -import { zeroBN } from 'utils/formatters/number'; +import { formatCurrency, formatDollars, zeroBN } from 'utils/formatters/number'; +import { MarketAssetByKey } from 'utils/futures'; import logError from 'utils/logError'; export const getFuturesEndpoint = (networkId: number): string => { @@ -285,3 +289,35 @@ export const calculateCrossMarginFee = ( orderType === 'limit' ? feeRates.limitOrderFee : feeRates.stopOrderFee; return susdSize.mul(advancedOrderFeeRate); }; + +export const mapFuturesOrderFromEvent = ( + o: OrderPlacedEvent, + account: string, + timestamp: Wei +): FuturesOrder => { + const marketKey = parseBytes32String(o.args.marketKey) as FuturesMarketKey; + const asset = MarketAssetByKey[marketKey]; + const sizeDelta = wei(o.args.sizeDelta); + const size = sizeDelta.abs(); + return { + id: `CM-${account}-${o.args.orderId}`, + account: account, + size: sizeDelta, + marginDelta: wei(o.args.marginDelta), + orderType: o.args.orderType === 0 ? 'Limit' : 'Stop Market', + targetPrice: wei(o.args.targetPrice), + sizeTxt: formatCurrency(asset, size, { + currencyKey: getDisplayAsset(asset) ?? '', + minDecimals: size.lt(0.01) ? 4 : 2, + }), + targetPriceTxt: formatDollars(wei(o.args.targetPrice)), + timestamp: timestamp, + marketKey: marketKey, + market: getMarketName(asset), + asset: asset, + targetRoundId: wei(0), // Only used for next price which is no longer supported + side: sizeDelta.gt(0) ? PositionSide.LONG : PositionSide.SHORT, + isStale: false, + isExecutable: false, + }; +}; From 4c53230e9fbbc36cffc95efe91999c6c89f3968c Mon Sep 17 00:00:00 2001 From: leifu Date: Fri, 6 Jan 2023 13:31:19 +0200 Subject: [PATCH 2/4] Fixed the wrong reward badge after the market page refresh (#1836) * Fixed the issue that showing the wrong reward badge after page refresh * Move the staking data fetch to the hook * Cleaned the unnecessary changes --- sections/futures/FeeInfoBox/FeeInfoBox.tsx | 12 ++---------- state/futures/hooks.ts | 2 ++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sections/futures/FeeInfoBox/FeeInfoBox.tsx b/sections/futures/FeeInfoBox/FeeInfoBox.tsx index 0e5c49e32e..17ec23afa8 100644 --- a/sections/futures/FeeInfoBox/FeeInfoBox.tsx +++ b/sections/futures/FeeInfoBox/FeeInfoBox.tsx @@ -1,5 +1,5 @@ import router from 'next/router'; -import React, { FC, useMemo, useEffect } from 'react'; +import React, { FC, useMemo } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import styled from 'styled-components'; @@ -22,8 +22,7 @@ import { selectOrderType, selectTradeSizeInputs, } from 'state/futures/selectors'; -import { useAppDispatch, useAppSelector } from 'state/hooks'; -import { fetchStakingData } from 'state/staking/actions'; +import { useAppSelector } from 'state/hooks'; import { selectStakedEscrowedKwentaBalance, selectStakedKwentaBalance, @@ -35,7 +34,6 @@ import { formatCurrency, formatDollars, formatPercent, zeroBN } from 'utils/form const FeeInfoBox: React.FC = () => { const { t } = useTranslation(); const { walletAddress } = Connector.useContainer(); - const dispatch = useAppDispatch(); const orderType = useAppSelector(selectOrderType); const stakedEscrowedKwentaBalance = useAppSelector(selectStakedEscrowedKwentaBalance); const stakedKwentaBalance = useAppSelector(selectStakedKwentaBalance); @@ -82,12 +80,6 @@ const FeeInfoBox: React.FC = () => { [walletAddress, stakedKwentaBalance, stakedEscrowedKwentaBalance] ); - useEffect(() => { - if (!!walletAddress) { - dispatch(fetchStakingData()); - } - }, [dispatch, walletAddress]); - const feesInfo = useMemo>(() => { const crossMarginFeeInfo = { 'Protocol Fee': { diff --git a/state/futures/hooks.ts b/state/futures/hooks.ts index 7f3b4367cc..0c59abd230 100644 --- a/state/futures/hooks.ts +++ b/state/futures/hooks.ts @@ -1,4 +1,5 @@ import { useAppSelector, useFetchAction, usePollAction } from 'state/hooks'; +import { fetchStakingData } from 'state/staking/actions'; import { selectNetwork, selectWallet } from 'state/wallet/selectors'; import { @@ -21,6 +22,7 @@ export const usePollMarketFuturesData = () => { const selectedAccountType = useAppSelector(selectFuturesType); useFetchAction(fetchCrossMarginSettings, { changeKeys: [networkId] }); + useFetchAction(fetchStakingData, { changeKeys: [networkId, wallet] }); usePollAction('fetchSharedFuturesData', fetchSharedFuturesData, { dependencies: [networkId], intervalTime: 60000, From a96397b6aaf3d60d02e782141f0a318f119b1293 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Fri, 6 Jan 2023 14:35:53 -0700 Subject: [PATCH 3/4] Perps Alpha Link (#1843) * add link to perps v2 alpha * add badge * fix theming --- assets/svg/app/link-light.svg | 3 +++ components/Nav/DropDownLabel.tsx | 13 ++++++--- constants/links.ts | 1 + .../Layout/AppLayout/Header/Nav/Nav.tsx | 27 ++++++++++++------- .../Layout/AppLayout/Header/constants.tsx | 14 ++++++++++ translations/en.json | 2 ++ 6 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 assets/svg/app/link-light.svg diff --git a/assets/svg/app/link-light.svg b/assets/svg/app/link-light.svg new file mode 100644 index 0000000000..c1b01a5dd4 --- /dev/null +++ b/assets/svg/app/link-light.svg @@ -0,0 +1,3 @@ + + + diff --git a/components/Nav/DropDownLabel.tsx b/components/Nav/DropDownLabel.tsx index e69dabe02c..e6a3e7e1c9 100644 --- a/components/Nav/DropDownLabel.tsx +++ b/components/Nav/DropDownLabel.tsx @@ -2,13 +2,17 @@ import styled from 'styled-components'; import { FlexDivRow } from 'styles/common'; -export const LabelContainer = styled(FlexDivRow)<{ noPadding?: boolean }>` +export const LabelContainer = styled(FlexDivRow)<{ noPadding?: boolean; external?: boolean }>` padding: ${(props) => !props.noPadding && '16px'}; font-size: 13px; align-items: center; font-family: ${(props) => props.theme.fonts.regular}; width: 100%; - color: ${(props) => props.theme.colors.selectedTheme.button.text.primary}; + color: ${(props) => + props.external + ? props.theme.colors.selectedTheme.button.yellow.text + : props.theme.colors.selectedTheme.button.text.primary}; + :hover { > svg { path { @@ -18,7 +22,10 @@ export const LabelContainer = styled(FlexDivRow)<{ noPadding?: boolean }>` } > svg { path { - fill: ${(props) => props.theme.colors.selectedTheme.icon.fill}; + fill: ${(props) => + props.external + ? props.theme.colors.selectedTheme.white + : props.theme.colors.selectedTheme.icon.fill}; } } `; diff --git a/constants/links.ts b/constants/links.ts index d8f9e91642..72e27f0bd0 100644 --- a/constants/links.ts +++ b/constants/links.ts @@ -48,6 +48,7 @@ export const EXTERNAL_LINKS = { }, Trade: { NextPriceBlogPost: 'https://docs.kwenta.io/products/futures/next-price', + PerpsV2: 'https://alpha.kwenta.eth.limo/market/?accountType=isolated_margin&asset=sETH', }, Governance: { Kips: 'https://kips.kwenta.io/all-kip/', diff --git a/sections/shared/Layout/AppLayout/Header/Nav/Nav.tsx b/sections/shared/Layout/AppLayout/Header/Nav/Nav.tsx index 2e2a094551..fc33dd3293 100644 --- a/sections/shared/Layout/AppLayout/Header/Nav/Nav.tsx +++ b/sections/shared/Layout/AppLayout/Header/Nav/Nav.tsx @@ -21,6 +21,7 @@ type ReactSelectOptionProps = { link: string; badge: BadgeType[]; Icon: FunctionComponent; + externalLink?: boolean; }; const Nav: FC = () => { @@ -38,6 +39,7 @@ const Nav: FC = () => { badge, link, isActive, + externalLink, }: ReactSelectOptionProps) => { if (i18nLabel === 'header.nav.markets' || i18nLabel === 'header.nav.leaderboard') return ( @@ -47,14 +49,16 @@ const Nav: FC = () => { ); return ( - - - {t(i18nLabel)} - {badge && - badge.map(({ i18nLabel, color }) => {t(i18nLabel)})} - - {Icon && } - + + + + {t(i18nLabel)} + {badge && + badge.map(({ i18nLabel, color }) => {t(i18nLabel)})} + + {Icon && } + + ); }; @@ -142,7 +146,6 @@ const DropDownSelect = styled(Select)` padding: 20px; .react-select__group-heading { - color: ${(props) => props.theme.colors.selectedTheme.button.text.primary}; font-size: 12px; padding: 0; margin-bottom: 15px; @@ -156,6 +159,12 @@ const DropDownSelect = styled(Select)` padding: 0; } + .react-select__menu-list { + .react-select__option:last-child { + background-color: ${(props) => props.theme.colors.selectedTheme.button.yellow.fill}; + } + } + .react-select__value-container { padding: 0px; width: ${(props) => { diff --git a/sections/shared/Layout/AppLayout/Header/constants.tsx b/sections/shared/Layout/AppLayout/Header/constants.tsx index 7299487af4..bbf8ed832c 100644 --- a/sections/shared/Layout/AppLayout/Header/constants.tsx +++ b/sections/shared/Layout/AppLayout/Header/constants.tsx @@ -1,5 +1,6 @@ import { FunctionComponent } from 'react'; +import LinkIconLight from 'assets/svg/app/link-light.svg'; import { CrossMarginIcon, IsolatedMarginIcon } from 'components/Nav/FuturesIcon'; import { COMPETITION_ENABLED } from 'constants/competition'; import { CROSS_MARGIN_ENABLED, DEFAULT_FUTURES_MARGIN_TYPE } from 'constants/defaults'; @@ -16,6 +17,7 @@ export type SubMenuLink = { link: string; badge?: Badge[]; Icon?: FunctionComponent; + externalLink?: boolean; }; export type MenuLink = { @@ -99,6 +101,18 @@ export const getMenuLinks = (isMobile: boolean): MenuLinks => [ ], Icon: CrossMarginIcon, }, + { + link: EXTERNAL_LINKS.Trade.PerpsV2, + externalLink: true, + i18nLabel: 'header.nav.v2-alpha', + badge: [ + { + i18nLabel: 'header.nav.alpha-badge', + color: 'red', + }, + ], + Icon: LinkIconLight, + }, ] : null, }, diff --git a/translations/en.json b/translations/en.json index 9bf9bf9267..a49616d566 100644 --- a/translations/en.json +++ b/translations/en.json @@ -16,11 +16,13 @@ "markets": "futures", "isolated-margin": "Isolated Margin", "cross-margin": "Cross Margin", + "v2-alpha": "Try Futures V2 Alpha", "leaderboard-alltime": "All Time", "competition-round-1": "Round 1", "competition-round-2": "Round 2", "leaderboard": "leaderboard", "earn": "earn", + "alpha-badge": "Alpha", "beta-badge": "Beta", "reward-badge": "Rewards" }, From 37accffa3fd811a8864cc01fd1fb02b1e48cd5a0 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Tue, 10 Jan 2023 03:26:02 -0700 Subject: [PATCH 4/4] Perps V1: Switch to testnet subgraph (#1852) * switch to testnet subgraph * remove import * fix 24h price --- components/TVChart/DataFeed.ts | 4 +- queries/rates/constants.ts | 2 +- queries/rates/types.ts | 2 +- queries/rates/useLaggedDailyPrice.ts | 50 ++++++++++--------- queries/rates/utils.ts | 4 +- .../FuturesMarketsTable.tsx | 3 +- .../futures/MarketDetails/useGetMarketData.ts | 3 +- 7 files changed, 37 insertions(+), 31 deletions(-) diff --git a/components/TVChart/DataFeed.ts b/components/TVChart/DataFeed.ts index a5e22450f3..edf44ee94b 100644 --- a/components/TVChart/DataFeed.ts +++ b/components/TVChart/DataFeed.ts @@ -57,7 +57,7 @@ const fetchCombinedCandles = async ( const baseCurrencyIsSUSD = base === 'sUSD'; const quoteCurrencyIsSUSD = quote === 'sUSD'; const baseDataPromise = requestCandlesticks( - base, + getDisplayAsset(base), from, to, resolutionToSeconds(resolution), @@ -88,7 +88,7 @@ const fetchLastCandle = async ( const from = 0; const baseDataPromise = requestCandlesticks( - base, + getDisplayAsset(base), from, to, resolutionToSeconds(resolution), diff --git a/queries/rates/constants.ts b/queries/rates/constants.ts index b79e6c3065..9a4b10498a 100644 --- a/queries/rates/constants.ts +++ b/queries/rates/constants.ts @@ -3,7 +3,7 @@ import { chain } from 'wagmi'; export const RATES_ENDPOINT_MAIN = 'https://api.thegraph.com/subgraphs/name/kwenta/mainnet-main'; export const RATES_ENDPOINT_OP_MAINNET = - 'https://api.thegraph.com/subgraphs/name/kwenta/optimism-main'; + 'https://api.thegraph.com/subgraphs/name/kwenta/optimism-goerli-main'; export const RATES_ENDPOINT_OP_GOERLI = 'https://api.thegraph.com/subgraphs/name/kwenta/optimism-goerli-main'; diff --git a/queries/rates/types.ts b/queries/rates/types.ts index 496e104d50..42d648f815 100644 --- a/queries/rates/types.ts +++ b/queries/rates/types.ts @@ -54,7 +54,7 @@ export type Candle = { export type Candles = Candle[]; export type LatestRate = { - id: string; + synth: string; rate: Wei; }; diff --git a/queries/rates/useLaggedDailyPrice.ts b/queries/rates/useLaggedDailyPrice.ts index 6834368d20..475a477fca 100644 --- a/queries/rates/useLaggedDailyPrice.ts +++ b/queries/rates/useLaggedDailyPrice.ts @@ -1,5 +1,4 @@ import { NetworkId } from '@synthetixio/contracts-interface'; -import EthDater from 'ethereum-block-by-date'; import request, { gql } from 'graphql-request'; import { values } from 'lodash'; import { useQuery, UseQueryOptions } from 'react-query'; @@ -8,21 +7,22 @@ import { useSetRecoilState } from 'recoil'; import QUERY_KEYS from 'constants/queryKeys'; import ROUTES from 'constants/routes'; import Connector from 'containers/Connector'; +import { getDisplayAsset } from 'sdk/utils/futures'; import { selectMarketAssets } from 'state/futures/selectors'; import { useAppSelector } from 'state/hooks'; import { pastRatesState } from 'store/futures'; import logError from 'utils/logError'; import { RATES_ENDPOINT_OP_MAINNET } from './constants'; -import { Price } from './types'; +import { LatestRate, Price } from './types'; import { getRatesEndpoint, mapLaggedDailyPrices } from './utils'; const useLaggedDailyPrice = (options?: UseQueryOptions) => { - const { provider, network, synthsMap } = Connector.useContainer(); + const { network, synthsMap } = Connector.useContainer(); const marketAssets = useAppSelector(selectMarketAssets); const setPastRates = useSetRecoilState(pastRatesState); - const minTimestamp = Math.floor(Date.now()) - 60 * 60 * 24 * 1000; + const minTimestamp = Math.floor((Date.now() - 60 * 60 * 24 * 1000) / 1000); const synths = [...marketAssets, ...values(synthsMap).map(({ name }) => name)]; const ratesEndpoint = @@ -33,32 +33,36 @@ const useLaggedDailyPrice = (options?: UseQueryOptions) => { return useQuery( QUERY_KEYS.Rates.PastRates(network?.id as NetworkId, synths), async () => { - if (!provider) return null; - const dater = new EthDater(provider); - - const block = await dater.getDate(minTimestamp, true, false); - try { + const rateUpdateQueries = synths.map((synth) => { + return gql` + # last before timestamp + ${synth}: rateUpdates( + first: 1 + where: { synth: "${getDisplayAsset(synth) ?? synth}", timestamp_gte: $minTimestamp } + orderBy: timestamp + orderDirection: asc + ) { + synth + rate + } + `; + }); + const response = await request( ratesEndpoint, gql` - query latestRates($synths: [String!]!) { - latestRates( - where: { - id_in: $synths - } - block: { number: ${block.block} } - ) { - id - rate - } - } - `, + query rateUpdates($minTimestamp: BigInt!) { + ${rateUpdateQueries.reduce((acc: string, curr: string) => { + return acc + curr; + })} + }`, { - synths: synths, + minTimestamp: minTimestamp, } ); - const pastRates = response ? mapLaggedDailyPrices(response.latestRates) : []; + const latestRates = (response ? Object.values(response).flat() : []) as LatestRate[]; + const pastRates = mapLaggedDailyPrices(latestRates); setPastRates(pastRates); return pastRates; diff --git a/queries/rates/utils.ts b/queries/rates/utils.ts index 507876de69..f65f76d581 100644 --- a/queries/rates/utils.ts +++ b/queries/rates/utils.ts @@ -17,9 +17,9 @@ export const getRatesEndpoint = (networkId: NetworkId): string => { export const mapLaggedDailyPrices = (rates: LatestRate[]): Prices => { return rates.map((rate) => { return { - synth: rate.id, + synth: rate.synth, price: - rate.id === 'DebtRatio' + rate.synth === 'DebtRatio' ? wei(rate.rate).div(DEBT_RATIO_UNIT).toNumber() : wei(rate.rate).toNumber(), }; diff --git a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx index 393ee36e83..1b09afc3e5 100644 --- a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx +++ b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx @@ -15,6 +15,7 @@ import { DEFAULT_CRYPTO_DECIMALS } from 'constants/defaults'; import ROUTES from 'constants/routes'; import Connector from 'containers/Connector'; import { FundingRateResponse } from 'sdk/types/futures'; +import { getDisplayAsset } from 'sdk/utils/futures'; import { selectAverageFundingRates, selectFuturesType, @@ -40,7 +41,7 @@ const FuturesMarketsTable: FC = () => { return futuresMarkets.map((market) => { const description = getSynthDescription(market.asset, synthsMap, t); const volume = futuresVolumes[market.assetHex]?.volume; - const pastPrice = pastRates.find((price) => price.synth === market.asset); + const pastPrice = pastRates.find((price) => price.synth === getDisplayAsset(market.asset)); const fundingRate = fundingRates.find( (funding) => (funding as FundingRateResponse)?.asset === MarketKeyByAsset[market.asset] ); diff --git a/sections/futures/MarketDetails/useGetMarketData.ts b/sections/futures/MarketDetails/useGetMarketData.ts index 637984e29b..abd6bb7678 100644 --- a/sections/futures/MarketDetails/useGetMarketData.ts +++ b/sections/futures/MarketDetails/useGetMarketData.ts @@ -7,6 +7,7 @@ import { DEFAULT_CRYPTO_DECIMALS } from 'constants/defaults'; import { NO_VALUE } from 'constants/placeholder'; import useSelectedPriceCurrency from 'hooks/useSelectedPriceCurrency'; import useExternalPriceQuery from 'queries/rates/useExternalPriceQuery'; +import { getDisplayAsset } from 'sdk/utils/futures'; import { selectFundingRate, selectMarketAsset, @@ -44,7 +45,7 @@ const useGetMarketData = (mobile?: boolean) => { ? DEFAULT_CRYPTO_DECIMALS : undefined; - const pastPrice = pastRates.find((price) => price.synth === marketAsset); + const pastPrice = pastRates.find((price) => price.synth === getDisplayAsset(marketAsset)); const fundingTitle = useMemo( () => `${fundingRate?.fundingTitle ?? t('futures.market.info.hourly-funding')}`,