From f0968a973a1817de965fa52088e6be9a9ad98e79 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Fri, 27 Jan 2023 07:01:28 -0700 Subject: [PATCH 1/7] improve deposit button logic (#1919) improve flickering --- sdk/services/futures.ts | 14 ++++++-------- sections/futures/Trade/TradePanelHeader.tsx | 6 ++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sdk/services/futures.ts b/sdk/services/futures.ts index 0b127135e4..109cbd3262 100644 --- a/sdk/services/futures.ts +++ b/sdk/services/futures.ts @@ -247,14 +247,12 @@ export default class FuturesService { )) as boolean[]; // map the positions using the results - const positions = positionDetails - .map((position, ind) => { - const canLiquidate = canLiquidateState[ind]; - const marketKey = futuresMarkets[ind].marketKey; - const asset = futuresMarkets[ind].asset; - return mapFuturesPosition(position, canLiquidate, asset, marketKey); - }) - .filter(({ remainingMargin }) => remainingMargin.gt(0)); + const positions = positionDetails.map((position, ind) => { + const canLiquidate = canLiquidateState[ind]; + const marketKey = futuresMarkets[ind].marketKey; + const asset = futuresMarkets[ind].asset; + return mapFuturesPosition(position, canLiquidate, asset, marketKey); + }); return positions; } diff --git a/sections/futures/Trade/TradePanelHeader.tsx b/sections/futures/Trade/TradePanelHeader.tsx index 1e95762d2e..b774baccbc 100644 --- a/sections/futures/Trade/TradePanelHeader.tsx +++ b/sections/futures/Trade/TradePanelHeader.tsx @@ -10,9 +10,8 @@ import { NumberDiv } from 'components/Text/NumberLabel'; import { EXTERNAL_LINKS } from 'constants/links'; import { FuturesAccountType } from 'queries/futures/subgraph'; import { setOpenModal } from 'state/app/reducer'; -import { selectPosition, selectPositionStatus } from 'state/futures/selectors'; +import { selectPosition } from 'state/futures/selectors'; import { useAppDispatch, useAppSelector } from 'state/hooks'; -import { FetchStatus } from 'state/types'; import { selectWallet } from 'state/wallet/selectors'; import { BorderedPanel, YellowIconButton } from 'styles/common'; import { formatDollars, zeroBN } from 'utils/formatters/number'; @@ -30,7 +29,6 @@ export default function TradePanelHeader({ accountType, onManageBalance }: Props const wallet = useAppSelector(selectWallet); const { openConnectModal } = useConnectModal(); const position = useAppSelector(selectPosition); - const positionStatus = useAppSelector(selectPositionStatus); const balance = position ? position.remainingMargin : null; if (!wallet) { @@ -41,7 +39,7 @@ export default function TradePanelHeader({ accountType, onManageBalance }: Props ); } - if (!balance && positionStatus.status === FetchStatus.Success) { + if (!!balance && balance.eq(0)) { return ( Date: Sat, 28 Jan 2023 09:37:55 -0300 Subject: [PATCH 2/7] update KIPs link, remove indices from title (#1921) --- constants/links.ts | 3 ++- translations/en.json | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/constants/links.ts b/constants/links.ts index 82fcf9d8a9..0352ae7c46 100644 --- a/constants/links.ts +++ b/constants/links.ts @@ -50,7 +50,8 @@ export const EXTERNAL_LINKS = { NextPriceBlogPost: 'https://docs.kwenta.io/products/futures/next-price', }, Governance: { - Kips: 'https://kips.kwenta.io/all-kip/', + Kips: + 'https://app.radicle.xyz/seeds/maple.radicle.garden/rad:git:hnrkq1oex148yz4zi9tm7spfnjaryyuc93yay/tree/master', Vote: 'https://snapshot.org/#/kwenta.eth', }, Competition: { diff --git a/translations/en.json b/translations/en.json index 6b9c9de2e2..523586aec2 100644 --- a/translations/en.json +++ b/translations/en.json @@ -3,7 +3,7 @@ "en": "English" }, "meta": { - "description": "Gain exposure to cryptocurrencies, forex, indices, and commodities on Ethereum with zero slippage", + "description": "Gain exposure to cryptocurrencies, forex and commodities on Ethereum with zero slippage", "og": { "title": "Kwenta", "site-name": "Kwenta" @@ -52,7 +52,7 @@ "governance": { "title": "Governance", "overview": "Overview", - "kips": "KIPs" + "kips": "Kwenta State Log" }, "socials": { "title": "Socials", @@ -70,9 +70,7 @@ "assets": { "title": "UNIQUE MARKETS", "description": "Backed by Chainlink Oracles", - "index": "Unique Indices", "forex": "Forex", - "equities": "Traditional Equities", "crypto": "Cryptocurrencies", "commodity": "Commodities", "short": "Short positions" @@ -284,7 +282,7 @@ "governance": "Governance", "dev-dao": "Dev DAO", "marketing-dao": "Marketing DAO", - "kips": "KIPs" + "kips": "Kwenta State Log" } } }, From f02a9d9b428ff3c93a3ed9bbc2a4db6b053afe62 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Mon, 30 Jan 2023 07:30:28 -0700 Subject: [PATCH 3/7] remove funding adjustment (#1918) remove adjustment --- sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx | 2 +- sections/futures/MarketDetails/useGetMarketData.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx index ef2e368d5a..c707cca81e 100644 --- a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx +++ b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx @@ -48,7 +48,7 @@ const FuturesMarketsTable: FC = () => { volume: volume?.toNumber() ?? 0, pastPrice: pastPrice?.price, priceChange: pastPrice?.price && marketPrice.sub(pastPrice?.price).div(marketPrice), - fundingRate: market.currentFundingRate.div(marketPrice) ?? null, + fundingRate: market.currentFundingRate ?? null, openInterest: market.marketSize.mul(marketPrice), openInterestNative: market.marketSize, longInterest: market.marketSize.add(market.marketSkew).div('2').abs().mul(marketPrice), diff --git a/sections/futures/MarketDetails/useGetMarketData.ts b/sections/futures/MarketDetails/useGetMarketData.ts index bffcd06882..be49ec8098 100644 --- a/sections/futures/MarketDetails/useGetMarketData.ts +++ b/sections/futures/MarketDetails/useGetMarketData.ts @@ -49,8 +49,7 @@ const useGetMarketData = (mobile?: boolean) => { const oraclePrice = marketPrices.onChain ?? wei(0); const data: MarketData = useMemo(() => { - // TODO: remove this hard-coded display fix for funding - const fundingValue = marketInfo?.currentFundingRate.div(oraclePrice); + const fundingValue = marketInfo?.currentFundingRate; const marketName = `${marketInfo?.marketName ?? t('futures.market.info.default-market')}`; From 433b105bb3393ef895bbb7503177bd3fdedf9074 Mon Sep 17 00:00:00 2001 From: Flocqst <123545417+Flocqst@users.noreply.github.com> Date: Mon, 30 Jan 2023 15:37:09 +0100 Subject: [PATCH 4/7] fix: small design improvements (#1920) * center text span on Long/Short Market buttons * change open order side badge color according to selected theme * Adjust labels from mobile staking reward page --- .../dashboard/Stake/TradingRewardsTab.tsx | 141 ++++++++++++------ .../PositionButtons/PositionButtons.tsx | 1 - sections/futures/PositionType.tsx | 4 +- translations/en.json | 3 + 4 files changed, 102 insertions(+), 47 deletions(-) diff --git a/sections/dashboard/Stake/TradingRewardsTab.tsx b/sections/dashboard/Stake/TradingRewardsTab.tsx index b8239dd853..8e4ed061ac 100644 --- a/sections/dashboard/Stake/TradingRewardsTab.tsx +++ b/sections/dashboard/Stake/TradingRewardsTab.tsx @@ -27,6 +27,7 @@ import { selectEpochPeriod, selectResetTime, selectTotalRewards } from 'state/st import media from 'styles/media'; import { formatTruncatedDuration } from 'utils/formatters/date'; import { formatDollars, formatPercent, truncateNumbers, zeroBN } from 'utils/formatters/number'; +import { MobileHiddenView, MobileOnlyView } from 'components/Media'; const TradingRewardsTab: FC = memo( ({ period = 0, start = 0, end = Math.floor(Date.now() / 1000) }) => { @@ -109,55 +110,106 @@ const TradingRewardsTab: FC = memo( - - - - - - {t('dashboard.stake.tabs.trading-rewards.future-fee-paid', { - EpochPeriod: period, - })} - - - {formatDollars(futuresFeePaid, { minDecimals: 2 })} - - - - -
- - {t('dashboard.stake.tabs.trading-rewards.fees-paid', { EpochPeriod: period })} - - {formatDollars(totalFuturesFeePaid, { minDecimals: 2 })} -
- {showEstimatedValue ? ( - <> -
- {t('dashboard.stake.tabs.trading-rewards.estimated-rewards')} - {truncateNumbers(wei(estimatedReward), 4)} -
-
+ + + + + - {t('dashboard.stake.tabs.trading-rewards.estimated-reward-share', { + {t('dashboard.stake.tabs.trading-rewards.future-fee-paid', { EpochPeriod: period, })} - {formatPercent(ratio, { minDecimals: 2 })} -
- + + {formatDollars(futuresFeePaid, { minDecimals: 2 })} + + + + +
+ + {t('dashboard.stake.tabs.trading-rewards.fees-paid', { EpochPeriod: period })} + + {formatDollars(totalFuturesFeePaid, { minDecimals: 2 })} +
+ {showEstimatedValue ? ( + <> +
+ {t('dashboard.stake.tabs.trading-rewards.estimated-rewards')} + {truncateNumbers(wei(estimatedReward), 4)} +
+
+ + {t('dashboard.stake.tabs.trading-rewards.estimated-reward-share', { + EpochPeriod: period, + })} + + {formatPercent(ratio, { minDecimals: 2 })} +
+ + ) : null} +
+ {showEstimatedValue ? ( + + + {t('dashboard.stake.tabs.trading-rewards.estimated-info')} + + ) : null} - - {showEstimatedValue ? ( - - {t('dashboard.stake.tabs.trading-rewards.estimated-info')} - - ) : null} -
+ + + + + + + + {t('dashboard.stake.tabs.trading-rewards.future-fee-paid-mobile')} + + {formatDollars(futuresFeePaid, { minDecimals: 2 })} + + + + +
+ {t('dashboard.stake.tabs.trading-rewards.fees-paid-mobile')} + {formatDollars(totalFuturesFeePaid, { minDecimals: 2 })} +
+ {showEstimatedValue ? ( + <> +
+ {t('dashboard.stake.tabs.trading-rewards.estimated-rewards')} + {truncateNumbers(wei(estimatedReward), 4)} +
+
+ + {t('dashboard.stake.tabs.trading-rewards.estimated-reward-share-mobile', { + EpochPeriod: period, + })} + + {formatPercent(ratio, { minDecimals: 2 })} +
+ + ) : null} +
+ {showEstimatedValue ? ( + + + {t('dashboard.stake.tabs.trading-rewards.estimated-info')} + + + ) : null} +
+
); } @@ -199,6 +251,7 @@ const Value = styled(Body).attrs({ variant: 'bold', mono: true })` const Title = styled(Body).attrs({ size: 'medium' })` color: ${(props) => props.theme.colors.selectedTheme.title}; + white-space: nowrap; `; const CardGrid = styled.div` diff --git a/sections/futures/PositionButtons/PositionButtons.tsx b/sections/futures/PositionButtons/PositionButtons.tsx index fd67661d15..66b7506c48 100644 --- a/sections/futures/PositionButtons/PositionButtons.tsx +++ b/sections/futures/PositionButtons/PositionButtons.tsx @@ -65,7 +65,6 @@ const StyledPositionButton = styled(Button)` > span { position: relative; - top: -2px; } ${(props) => diff --git a/sections/futures/PositionType.tsx b/sections/futures/PositionType.tsx index 0235b7cbca..f510526744 100644 --- a/sections/futures/PositionType.tsx +++ b/sections/futures/PositionType.tsx @@ -25,12 +25,12 @@ const StyledText = styled.p<{ side: PositionSide }>` ${(props) => props.side === PositionSide.LONG ? css` - color: ${(props) => props.theme.colors.common.primaryGreen}; + color: ${(props) => props.theme.colors.selectedTheme.green}; background: rgba(127, 212, 130, 0.1); letter-spacing: 1.4px; ` : css` - color: ${(props) => props.theme.colors.common.primaryRed}; + color: ${(props) => props.theme.colors.selectedTheme.red}; background: rgba(239, 104, 104, 0.1); letter-spacing: -0.2px; `}; diff --git a/translations/en.json b/translations/en.json index 523586aec2..8860dc4aa2 100644 --- a/translations/en.json +++ b/translations/en.json @@ -524,9 +524,12 @@ "trading-rewards-tooltip": "Only trades made using a Kwenta Cross Margin account are eligible for trading rewards.", "spot-fee-paid": "Spot Fee Paid: Epoch {{EpochPeriod}}", "future-fee-paid": "Futures Fees Paid: Ep. {{EpochPeriod}}", + "future-fee-paid-mobile": "Futures Fees Paid", "fees-paid": "Total Fees in Pool: Ep. {{EpochPeriod}}", + "fees-paid-mobile": "Total Fees in Pool", "estimated-rewards": "Estimated Reward*", "estimated-reward-share": "Estimated Reward Share*", + "estimated-reward-share-mobile": "Est. Reward Share*", "trading-activity-reset": "Time until next epoch", "epoch": "Epoch {{EpochPeriod}}: {{EpochDate}}", "claimable-rewards-epoch": "Claimable Rewards: Epoch {{EpochPeriod}}", From 6b2e4230ed2ccbbb1c37b2e266855694aceff530 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Mon, 30 Jan 2023 08:31:47 -0700 Subject: [PATCH 5/7] fetch open orders using multicall (#1925) add orders function using multicall --- sdk/contracts/index.ts | 4 ++++ sdk/services/futures.ts | 19 ++++++++++++++++--- state/futures/actions.ts | 7 +++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/sdk/contracts/index.ts b/sdk/contracts/index.ts index 8edacfb1e4..1bcbcb9a72 100644 --- a/sdk/contracts/index.ts +++ b/sdk/contracts/index.ts @@ -11,6 +11,7 @@ import ExchangeRatesABI from './abis/ExchangeRates.json'; import FuturesMarketDataABI from './abis/FuturesMarketData.json'; import FuturesMarketSettingsABI from './abis/FuturesMarketSettings.json'; import KwentaStakingRewardsABI from './abis/KwentaStakingRewards.json'; +import PerpsV2MarketABI from './abis/PerpsV2Market.json'; import PerpsV2MarketDataABI from './abis/PerpsV2MarketData.json'; import PerpsV2MarketSettingsABI from './abis/PerpsV2MarketSettings.json'; import StakingRewardsABI from './abis/StakingRewards.json'; @@ -51,6 +52,9 @@ export type AllContractsMap = Record< { addresses: Partial>; Factory: ContractFactory } >; +export const getPerpsV2MarketMulticall = (marketAddress: string) => + new EthCallContract(marketAddress, PerpsV2MarketABI); + export const getContractsByNetwork = ( networkId: NetworkId, provider: ethers.providers.Provider | ethers.Signer diff --git a/sdk/services/futures.ts b/sdk/services/futures.ts index 109cbd3262..efd5709322 100644 --- a/sdk/services/futures.ts +++ b/sdk/services/futures.ts @@ -12,7 +12,7 @@ import { mapFuturesOrders } from 'queries/futures/utils'; import { UNSUPPORTED_NETWORK } from 'sdk/common/errors'; import { BPS_CONVERSION, DEFAULT_DESIRED_TIMEDELTA } from 'sdk/constants/futures'; import { Period, PERIOD_IN_SECONDS } from 'sdk/constants/period'; -import { getContractsByNetwork } from 'sdk/contracts'; +import { getContractsByNetwork, getPerpsV2MarketMulticall } from 'sdk/contracts'; import FuturesMarketABI from 'sdk/contracts/abis/FuturesMarket.json'; import FuturesMarketInternal from 'sdk/contracts/FuturesMarketInternal'; import { @@ -20,6 +20,7 @@ import { PerpsV2MarketData, PerpsV2Market__factory, } from 'sdk/contracts/types'; +import { IPerpsV2MarketConsolidated } from 'sdk/contracts/types/PerpsV2Market'; import { IPerpsV2MarketSettings } from 'sdk/contracts/types/PerpsV2MarketData'; import { NetworkOverrideOptions } from 'sdk/types/common'; import { @@ -509,11 +510,23 @@ export default class FuturesService { // Perps V2 read functions public async getDelayedOrder(account: string, marketAddress: string) { - const market = PerpsV2Market__factory.connect(marketAddress, this.sdk.context.signer); + const market = PerpsV2Market__factory.connect(marketAddress, this.sdk.context.provider); const order = await market.delayedOrders(account); return formatDelayedOrder(account, marketAddress, order); } + public async getDelayedOrders(account: string, marketAddresses: string[]) { + const marketContracts = marketAddresses.map(getPerpsV2MarketMulticall); + + const orders = (await this.sdk.context.multicallProvider.all( + marketContracts.map((market) => market.delayedOrders(account)) + )) as IPerpsV2MarketConsolidated.DelayedOrderStructOutput[]; + + return orders.map((order, ind) => { + return formatDelayedOrder(account, marketAddresses[ind], order); + }); + } + public async getIsolatedTradePreview( marketAddress: string, orderType: OrderType, @@ -524,7 +537,7 @@ export default class FuturesService { leverageSide: PositionSide; } ) { - const market = PerpsV2Market__factory.connect(marketAddress, this.sdk.context.signer); + const market = PerpsV2Market__factory.connect(marketAddress, this.sdk.context.provider); const details = await market.postTradeDetails( inputs.sizeDelta.toBN(), inputs.price.toBN(), diff --git a/state/futures/actions.ts b/state/futures/actions.ts index cb59712d91..f3cf583496 100644 --- a/state/futures/actions.ts +++ b/state/futures/actions.ts @@ -316,10 +316,9 @@ export const fetchOpenOrders = createAsyncThunk< if (markets.length === 0) { throw new Error('No markets available'); } - // TODO: Make this multicall - const orders: DelayedOrder[] = await Promise.all( - markets.map((market) => sdk.futures.getDelayedOrder(account, market.market)) - ); + const marketAddresses = markets.map((market) => market.market); + + const orders: DelayedOrder[] = await sdk.futures.getDelayedOrders(account, marketAddresses); const nonzeroOrders = orders .filter((o) => o.size.abs().gt(0)) .map((o) => { From 87af2063983f93e8250c727e8eca6832f81ec7d9 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Mon, 30 Jan 2023 08:45:01 -0700 Subject: [PATCH 6/7] improve order types (#1922) improve order types --- constants/futures.ts | 4 ++-- hooks/useFuturesData.ts | 2 +- queries/futures/types.ts | 8 +------- sdk/types/futures.ts | 4 ++-- sdk/utils/futures.ts | 2 +- sections/futures/FeeInfoBox/FeeInfoBox.tsx | 6 +++--- sections/futures/LeverageInput/LeverageInput.tsx | 2 +- sections/futures/OrderSizing/OrderSizing.tsx | 2 +- .../futures/Trade/DelayedOrderConfirmationModal.tsx | 4 ++-- sections/futures/Trade/ManagePosition.tsx | 8 ++++---- sections/futures/Trade/OrderWarning.tsx | 2 +- sections/futures/Trade/TradeConfirmationModal.tsx | 2 +- sections/futures/Trade/TradeIsolatedMargin.tsx | 2 +- .../futures/TradeCrossMargin/CrossMarginInfoBox.tsx | 4 ++-- state/futures/actions.ts | 4 ++-- state/futures/reducer.ts | 2 +- state/futures/selectors.ts | 12 ++++++------ state/futures/types.ts | 4 ++-- utils/costCalculations.ts | 4 ++-- utils/futures.ts | 4 ++-- 20 files changed, 38 insertions(+), 44 deletions(-) diff --git a/constants/futures.ts b/constants/futures.ts index 1abe0a85f2..df9184fd99 100644 --- a/constants/futures.ts +++ b/constants/futures.ts @@ -2,8 +2,8 @@ import { wei } from '@synthetixio/wei'; import { FuturesOrderType } from 'queries/futures/types'; -export const ISOLATED_MARGIN_ORDER_TYPES: FuturesOrderType[] = ['delayed offchain', 'market']; -export const CROSS_MARGIN_ORDER_TYPES: FuturesOrderType[] = ['market', 'limit', 'stop market']; +export const ISOLATED_MARGIN_ORDER_TYPES: FuturesOrderType[] = ['delayedOffchain', 'market']; +export const CROSS_MARGIN_ORDER_TYPES: FuturesOrderType[] = ['market', 'limit', 'stopMarket']; export const ORDER_KEEPER_ETH_DEPOSIT = wei(0.01); export const DEFAULT_MAX_LEVERAGE = wei(10); export const DEFAULT_DELAYED_LEVERAGE_CAP = wei(100); diff --git a/hooks/useFuturesData.ts b/hooks/useFuturesData.ts index 982b733110..7fb7b64350 100644 --- a/hooks/useFuturesData.ts +++ b/hooks/useFuturesData.ts @@ -168,7 +168,7 @@ const useFuturesData = () => { switch (orderType) { case 'limit': return limitOrderFee; - case 'stop market': + case 'stopMarket': return stopOrderFee; default: return zeroBN; diff --git a/queries/futures/types.ts b/queries/futures/types.ts index ac08bc4af4..51e5f6b6ee 100644 --- a/queries/futures/types.ts +++ b/queries/futures/types.ts @@ -197,13 +197,7 @@ export type FuturesTradeInputs = { orderPrice?: Wei | undefined; }; -export type FuturesOrderType = - | 'market' - | 'next price' - | 'stop market' - | 'limit' - | 'delayed' - | 'delayed offchain'; +export type FuturesOrderType = 'market' | 'stopMarket' | 'limit' | 'delayed' | 'delayedOffchain'; export type SpotsFee = { timestamp: string; diff --git a/sdk/types/futures.ts b/sdk/types/futures.ts index 882d846cd5..80bb69b8da 100644 --- a/sdk/types/futures.ts +++ b/sdk/types/futures.ts @@ -169,13 +169,13 @@ export enum OrderType { export const OrderNameByType: Record = { [OrderType.MARKET]: 'market', [OrderType.DELAYED]: 'delayed', - [OrderType.DELAYED_OFFCHAIN]: 'delayed offchain', + [OrderType.DELAYED_OFFCHAIN]: 'delayedOffchain', }; export const OrderTypeByName: Record = { market: OrderType.MARKET, delayed: OrderType.DELAYED, - 'delayed offchain': OrderType.DELAYED_OFFCHAIN, + delayedOffchain: OrderType.DELAYED_OFFCHAIN, }; export type FuturesFilledPosition = { diff --git a/sdk/utils/futures.ts b/sdk/utils/futures.ts index bf76a5b2bb..1c7825bc40 100644 --- a/sdk/utils/futures.ts +++ b/sdk/utils/futures.ts @@ -443,7 +443,7 @@ export const calculateCrossMarginFee = ( susdSize: Wei, feeRates: CrossMarginSettings ) => { - if (orderType !== 'limit' && orderType !== 'stop market') return zeroBN; + if (orderType !== 'limit' && orderType !== 'stopMarket') return zeroBN; const advancedOrderFeeRate = orderType === 'limit' ? feeRates.limitOrderFee : feeRates.stopOrderFee; return susdSize.mul(advancedOrderFeeRate); diff --git a/sections/futures/FeeInfoBox/FeeInfoBox.tsx b/sections/futures/FeeInfoBox/FeeInfoBox.tsx index dbbfb7f3d6..3eac77406c 100644 --- a/sections/futures/FeeInfoBox/FeeInfoBox.tsx +++ b/sections/futures/FeeInfoBox/FeeInfoBox.tsx @@ -58,7 +58,7 @@ const FeeInfoBox: React.FC = () => { const orderFeeRate = useMemo( () => - orderType === 'limit' ? limitOrderFee : orderType === 'stop market' ? stopOrderFee : null, + orderType === 'limit' ? limitOrderFee : orderType === 'stopMarket' ? stopOrderFee : null, [orderType, stopOrderFee, limitOrderFee] ); @@ -152,7 +152,7 @@ const FeeInfoBox: React.FC = () => { }), }, }; - if (orderType === 'limit' || orderType === 'stop market') { + if (orderType === 'limit' || orderType === 'stopMarket') { return { ...crossMarginFeeInfo, 'Keeper Deposit': { @@ -162,7 +162,7 @@ const FeeInfoBox: React.FC = () => { }, }; } - if (orderType === 'delayed' || orderType === 'delayed offchain') { + if (orderType === 'delayed' || orderType === 'delayedOffchain') { return { 'Keeper Deposit': { value: !!marketInfo?.keeperDeposit ? formatDollars(marketInfo.keeperDeposit) : NO_VALUE, diff --git a/sections/futures/LeverageInput/LeverageInput.tsx b/sections/futures/LeverageInput/LeverageInput.tsx index ed0cc687c8..1d8c54fb17 100644 --- a/sections/futures/LeverageInput/LeverageInput.tsx +++ b/sections/futures/LeverageInput/LeverageInput.tsx @@ -84,7 +84,7 @@ const LeverageInput: FC = memo(() => { {modeButton} - {(orderType === 'delayed' || orderType === 'delayed offchain') && isDisclaimerDisplayed && ( + {(orderType === 'delayed' || orderType === 'delayedOffchain') && isDisclaimerDisplayed && ( {t('futures.market.trade.input.leverage.disclaimer')} diff --git a/sections/futures/OrderSizing/OrderSizing.tsx b/sections/futures/OrderSizing/OrderSizing.tsx index 723a33b363..db5d339613 100644 --- a/sections/futures/OrderSizing/OrderSizing.tsx +++ b/sections/futures/OrderSizing/OrderSizing.tsx @@ -87,7 +87,7 @@ const OrderSizing: React.FC = memo(({ disabled, isMobile }) => const showPosSizeHelper = position?.position?.size && - (orderType === 'limit' || orderType === 'stop market') && + (orderType === 'limit' || orderType === 'stopMarket') && position?.position.side !== selectedLeverageSide; const invalid = diff --git a/sections/futures/Trade/DelayedOrderConfirmationModal.tsx b/sections/futures/Trade/DelayedOrderConfirmationModal.tsx index a75fba7dce..6299fd5330 100644 --- a/sections/futures/Trade/DelayedOrderConfirmationModal.tsx +++ b/sections/futures/Trade/DelayedOrderConfirmationModal.tsx @@ -64,7 +64,7 @@ const DelayedOrderConfirmationModal: FC = () => { modifyIsolatedPositionEstimateGas({ sizeDelta: nativeSizeDelta, delayed: true, - offchain: orderType === 'delayed offchain', + offchain: orderType === 'delayedOffchain', }) ); }, [nativeSizeDelta, orderType, dispatch]); @@ -174,7 +174,7 @@ const DelayedOrderConfirmationModal: FC = () => { modifyIsolatedPosition({ sizeDelta: nativeSizeDelta, delayed: true, - offchain: orderType === 'delayed offchain', + offchain: orderType === 'delayedOffchain', }) ); }; diff --git a/sections/futures/Trade/ManagePosition.tsx b/sections/futures/Trade/ManagePosition.tsx index ae8c5ac462..2556eee902 100644 --- a/sections/futures/Trade/ManagePosition.tsx +++ b/sections/futures/Trade/ManagePosition.tsx @@ -101,7 +101,7 @@ const ManagePosition: React.FC = () => { orderType ); - if ((orderType === 'limit' || orderType === 'stop market') && !!invalidReason) + if ((orderType === 'limit' || orderType === 'stopMarket') && !!invalidReason) return invalidReason; if (susdSize.gt(maxUsdInputAmount)) return 'max_size_exceeded'; if (placeOrderTranslationKey === 'futures.market.trade.button.deposit-margin-minimum') @@ -111,7 +111,7 @@ const ManagePosition: React.FC = () => { return 'awaiting_preview'; if (orderType !== 'market' && isZero(orderPrice)) return 'pricerequired'; } else if (selectedAccountType === 'isolated_margin') { - if ((orderType === 'delayed' || orderType === 'delayed offchain') && !!openOrder) + if ((orderType === 'delayed' || orderType === 'delayedOffchain') && !!openOrder) return 'order_open'; } else if (isZero(susdSize)) { return 'size_required'; @@ -162,7 +162,7 @@ const ManagePosition: React.FC = () => { variant="danger" onClick={() => { if ( - (orderType === 'delayed' || orderType === 'delayed offchain') && + (orderType === 'delayed' || orderType === 'delayedOffchain') && position?.position?.size ) { const newTradeSize = position.position.size; @@ -198,7 +198,7 @@ const ManagePosition: React.FC = () => { {isConfirmationModalOpen && (selectedAccountType === 'cross_margin' ? ( - ) : orderType === 'delayed' || orderType === 'delayed offchain' ? ( + ) : orderType === 'delayed' || orderType === 'delayedOffchain' ? ( ) : ( diff --git a/sections/futures/Trade/OrderWarning.tsx b/sections/futures/Trade/OrderWarning.tsx index 8a349259dc..75e88978be 100644 --- a/sections/futures/Trade/OrderWarning.tsx +++ b/sections/futures/Trade/OrderWarning.tsx @@ -12,7 +12,7 @@ const OrderWarning: React.FC = () => { return (

- {orderType === 'delayed offchain' + {orderType === 'delayedOffchain' ? t('futures.market.trade.delayed-order.description') : t('futures.market.trade.market-order.description')}

diff --git a/sections/futures/Trade/TradeConfirmationModal.tsx b/sections/futures/Trade/TradeConfirmationModal.tsx index a6bd4a337d..6e65e29a10 100644 --- a/sections/futures/Trade/TradeConfirmationModal.tsx +++ b/sections/futures/Trade/TradeConfirmationModal.tsx @@ -102,7 +102,7 @@ export default function TradeConfirmationModal({ label: 'resulting leverage', value: `${formatNumber(positionDetails?.leverage ?? zeroBN)}x`, }, - orderType === 'limit' || orderType === 'stop market' + orderType === 'limit' || orderType === 'stopMarket' ? { label: orderType + ' order price', value: formatDollars(orderPrice, { isAssetPrice: true }), diff --git a/sections/futures/Trade/TradeIsolatedMargin.tsx b/sections/futures/Trade/TradeIsolatedMargin.tsx index 0a0397e044..6c18ee345a 100644 --- a/sections/futures/Trade/TradeIsolatedMargin.tsx +++ b/sections/futures/Trade/TradeIsolatedMargin.tsx @@ -54,7 +54,7 @@ const TradeIsolatedMargin = ({ isMobile }: Props) => { values={ISOLATED_MARGIN_ORDER_TYPES} selectedIndex={ISOLATED_MARGIN_ORDER_TYPES.indexOf(orderType)} onChange={(oType: number) => { - const newOrderType = oType === 1 ? 'market' : 'delayed offchain'; + const newOrderType = oType === 1 ? 'market' : 'delayedOffchain'; dispatch(setOrderType(newOrderType)); }} /> diff --git a/sections/futures/TradeCrossMargin/CrossMarginInfoBox.tsx b/sections/futures/TradeCrossMargin/CrossMarginInfoBox.tsx index ef4a9ca4a2..f5085fd48a 100644 --- a/sections/futures/TradeCrossMargin/CrossMarginInfoBox.tsx +++ b/sections/futures/TradeCrossMargin/CrossMarginInfoBox.tsx @@ -110,9 +110,9 @@ function MarginInfoBox({ editingLeverage }: Props) { return { showPreview: - ((orderType === 'market' || orderType === 'delayed' || orderType === 'delayed offchain') && + ((orderType === 'market' || orderType === 'delayed' || orderType === 'delayedOffchain') && (!size.eq(0) || !marginDelta.eq(0))) || - ((orderType === 'limit' || orderType === 'stop market') && !!orderPrice && !size.eq(0)), + ((orderType === 'limit' || orderType === 'stopMarket') && !!orderPrice && !size.eq(0)), totalMargin: potentialTrade?.margin.sub(crossMarginFee) || zeroBN, freeAccountMargin: crossMarginFreeMargin.sub(marginDelta), availableMargin: previewAvailableMargin.gt(0) ? previewAvailableMargin : zeroBN, diff --git a/state/futures/actions.ts b/state/futures/actions.ts index f3cf583496..12a9608269 100644 --- a/state/futures/actions.ts +++ b/state/futures/actions.ts @@ -611,7 +611,7 @@ export const calculateCrossMarginFees = (): AppThunk => (dispatch, getState) => const tradeFee = susdSize.mul(staticRate).add(susdSize.mul(dynamicFeeRate)); const currentDeposit = - orderType === 'limit' || orderType === 'stop market' ? keeperBalance : wei(0); + orderType === 'limit' || orderType === 'stopMarket' ? keeperBalance : wei(0); const requiredDeposit = currentDeposit.lt(ORDER_KEEPER_ETH_DEPOSIT) ? ORDER_KEEPER_ETH_DEPOSIT.sub(currentDeposit) : wei(0); @@ -799,7 +799,7 @@ export const modifyIsolatedPosition = createAsyncThunk< dispatch(updateTransactionHash(tx.hash)); await tx.wait(); dispatch(refetchPosition('isolated_margin')); - dispatch(setOrderType('delayed offchain')); + dispatch(setOrderType('delayedOffchain')); dispatch(setOpenModal(null)); dispatch(clearTradeInputs()); dispatch(fetchBalances()); diff --git a/state/futures/reducer.ts b/state/futures/reducer.ts index 6d0fd441d1..d9efdb6f8d 100644 --- a/state/futures/reducer.ts +++ b/state/futures/reducer.ts @@ -124,7 +124,7 @@ const initialState: FuturesState = { selectedMarketAsset: FuturesMarketAsset.sETH, selectedMarketKey: FuturesMarketKey.sETH, leverageSide: PositionSide.LONG, - orderType: 'delayed offchain', + orderType: 'delayedOffchain', tradePreview: null, tradeInputs: ZERO_STATE_TRADE_INPUTS, priceImpact: DEFAULT_PRICE_IMPACT_DELTA, diff --git a/state/futures/selectors.ts b/state/futures/selectors.ts index 1ea44486a4..5a4cafe441 100644 --- a/state/futures/selectors.ts +++ b/state/futures/selectors.ts @@ -344,7 +344,7 @@ export const selectMaxLeverage = createSelector( const positionSide = position?.position?.side; const marketMaxLeverage = market?.maxLeverage ?? DEFAULT_MAX_LEVERAGE; const adjustedMaxLeverage = - orderType === 'delayed' || orderType === 'delayed offchain' + orderType === 'delayed' || orderType === 'delayedOffchain' ? marketMaxLeverage.mul(DEFAULT_NP_LEVERAGE_ADJUSTMENT) : marketMaxLeverage; @@ -478,10 +478,10 @@ export const selectPlaceOrderTranslationKey = createSelector( remainingMargin = positionMargin.add(freeMargin); } - if (orderType === 'delayed' || orderType === 'delayed offchain') + if (orderType === 'delayed' || orderType === 'delayedOffchain') return 'futures.market.trade.button.place-delayed-order'; if (orderType === 'limit') return 'futures.market.trade.button.place-limit-order'; - if (orderType === 'stop market') return 'futures.market.trade.button.place-stop-order'; + if (orderType === 'stopMarket') return 'futures.market.trade.button.place-stop-order'; if (!!position?.position) return 'futures.market.trade.button.modify-position'; return remainingMargin.lt('50') ? 'futures.market.trade.button.deposit-margin-minimum' @@ -610,7 +610,7 @@ export const selectCrossMarginSettings = createSelector( export const selectIsAdvancedOrder = createSelector( (state: RootState) => state.futures.crossMargin.orderType, - (type) => type === 'limit' || type === 'stop market' + (type) => type === 'limit' || type === 'stopMarket' ); export const selectModifyIsolatedGasEstimate = createSelector( @@ -642,11 +642,11 @@ export const selectDelayedOrderFee = createSelector( const notionalDiff = nativeSizeDelta.mul(price); const makerFee = - orderType === 'delayed offchain' + orderType === 'delayedOffchain' ? market.feeRates.makerFeeOffchainDelayedOrder : market.feeRates.makerFeeDelayedOrder; const takerFee = - orderType === 'delayed offchain' + orderType === 'delayedOffchain' ? market.feeRates.takerFeeOffchainDelayedOrder : market.feeRates.takerFeeDelayedOrder; diff --git a/state/futures/types.ts b/state/futures/types.ts index d3cabf9727..d91eb5bc79 100644 --- a/state/futures/types.ts +++ b/state/futures/types.ts @@ -14,8 +14,8 @@ import { PositionSide } from 'sections/futures/types'; import { QueryStatus } from 'state/types'; import { FuturesMarketAsset, FuturesMarketKey } from 'utils/futures'; -export type IsolatedMarginOrderType = 'delayed' | 'delayed offchain' | 'market'; -export type CrossMarginOrderType = 'market' | 'stop market' | 'limit'; +export type IsolatedMarginOrderType = 'delayed' | 'delayedOffchain' | 'market'; +export type CrossMarginOrderType = 'market' | 'stopMarket' | 'limit'; export type TradeSizeInputs = { nativeSize: T; diff --git a/utils/costCalculations.ts b/utils/costCalculations.ts index aa04cdc296..de19de5968 100644 --- a/utils/costCalculations.ts +++ b/utils/costCalculations.ts @@ -57,13 +57,13 @@ export const computeOrderFee = ( } const makerFee = - orderType === 'delayed offchain' + orderType === 'delayedOffchain' ? market.feeRates.makerFeeOffchainDelayedOrder : orderType === 'delayed' ? market.feeRates.makerFeeDelayedOrder : market.feeRates.makerFee; const takerFee = - orderType === 'delayed offchain' + orderType === 'delayedOffchain' ? market.feeRates.takerFeeOffchainDelayedOrder : orderType === 'delayed' ? market.feeRates.takerFeeDelayedOrder diff --git a/utils/futures.ts b/utils/futures.ts index 87800464fc..a11a4ca752 100644 --- a/utils/futures.ts +++ b/utils/futures.ts @@ -184,12 +184,12 @@ export const orderPriceInvalidLabel = ( if (!orderPrice || Number(orderPrice) <= 0) return null; const isLong = leverageSide === 'long'; if ( - ((isLong && orderType === 'limit') || (!isLong && orderType === 'stop market')) && + ((isLong && orderType === 'limit') || (!isLong && orderType === 'stopMarket')) && wei(orderPrice).gt(currentPrice) ) return 'max ' + formatNumber(currentPrice); if ( - ((!isLong && orderType === 'limit') || (isLong && orderType === 'stop market')) && + ((!isLong && orderType === 'limit') || (isLong && orderType === 'stopMarket')) && wei(orderPrice).lt(currentPrice) ) return 'min ' + formatNumber(currentPrice); From 9161c9c3472e18feebd9e7f5f2958deedf38f514 Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Mon, 30 Jan 2023 09:21:48 -0700 Subject: [PATCH 7/7] add mark prices to state (#1923) mark price object for all markets --- sdk/types/futures.ts | 2 +- .../FuturesMarketsTable.tsx | 22 ++++++++++------- .../MarketDetails/MobileMarketDetail.tsx | 14 +++++------ sections/futures/TradingHistory/SkewInfo.tsx | 12 +++++----- state/futures/selectors.ts | 18 +++++++++++--- state/futures/types.ts | 2 ++ translations/en.json | 2 +- utils/futures.ts | 24 ++++++++----------- 8 files changed, 54 insertions(+), 42 deletions(-) diff --git a/sdk/types/futures.ts b/sdk/types/futures.ts index 80bb69b8da..84c19663f9 100644 --- a/sdk/types/futures.ts +++ b/sdk/types/futures.ts @@ -32,7 +32,7 @@ export type FuturesMarket = { makerFeeOffchainDelayedOrder: T; takerFeeOffchainDelayedOrder: T; }; - openInterest?: { + openInterest: { shortPct: number; longPct: number; shortUSD: T; diff --git a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx index c707cca81e..e6dabe0ac0 100644 --- a/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx +++ b/sections/dashboard/FuturesMarketsTable/FuturesMarketsTable.tsx @@ -15,9 +15,13 @@ import { DEFAULT_CRYPTO_DECIMALS } from 'constants/defaults'; import ROUTES from 'constants/routes'; import Connector from 'containers/Connector'; import { getDisplayAsset } from 'sdk/utils/futures'; -import { selectFuturesType, selectMarkets, selectMarketVolumes } from 'state/futures/selectors'; +import { + selectFuturesType, + selectMarkets, + selectMarketVolumes, + selectMarkPrices, +} from 'state/futures/selectors'; import { useAppSelector } from 'state/hooks'; -import { selectPrices } from 'state/prices/selectors'; import { pastRatesState } from 'store/futures'; import { getSynthDescription, MarketKeyByAsset, FuturesMarketAsset } from 'utils/futures'; @@ -30,14 +34,14 @@ const FuturesMarketsTable: FC = () => { const pastRates = useRecoilValue(pastRatesState); const futuresVolumes = useAppSelector(selectMarketVolumes); const accountType = useAppSelector(selectFuturesType); - const prices = useAppSelector(selectPrices); + const markPrices = useAppSelector(selectMarkPrices); let data = useMemo(() => { return futuresMarkets.map((market) => { const description = getSynthDescription(market.asset, synthsMap, t); const volume = futuresVolumes[market.marketKey]?.volume; const pastPrice = pastRates.find((price) => price.synth === getDisplayAsset(market.asset)); - const marketPrice = prices[market.asset]?.offChain ?? prices[market.asset]?.onChain ?? wei(0); + const marketPrice = markPrices[market.marketKey] ?? wei(0); return { asset: market.asset, @@ -51,14 +55,14 @@ const FuturesMarketsTable: FC = () => { fundingRate: market.currentFundingRate ?? null, openInterest: market.marketSize.mul(marketPrice), openInterestNative: market.marketSize, - longInterest: market.marketSize.add(market.marketSkew).div('2').abs().mul(marketPrice), - shortInterest: market.marketSize.sub(market.marketSkew).div('2').abs().mul(marketPrice), + longInterest: market.openInterest.longUSD, + shortInterest: market.openInterest.shortUSD, marketSkew: market.marketSkew, isSuspended: market.isSuspended, marketClosureReason: market.marketClosureReason, }; }); - }, [synthsMap, futuresMarkets, pastRates, futuresVolumes, prices, t]); + }, [synthsMap, futuresMarkets, pastRates, futuresVolumes, markPrices, t]); return ( <> @@ -103,10 +107,10 @@ const FuturesMarketsTable: FC = () => { { Header: ( - {t('dashboard.overview.futures-markets-table.oracle-price')} + {t('dashboard.overview.futures-markets-table.mark-price')} ), - accessor: 'oraclePrice', + accessor: 'price', Cell: (cellProps: CellProps) => { const formatOptions = { minDecimals: DEFAULT_CRYPTO_DECIMALS, diff --git a/sections/futures/MarketDetails/MobileMarketDetail.tsx b/sections/futures/MarketDetails/MobileMarketDetail.tsx index 0bbcbbd62d..8d82470b7c 100644 --- a/sections/futures/MarketDetails/MobileMarketDetail.tsx +++ b/sections/futures/MarketDetails/MobileMarketDetail.tsx @@ -12,10 +12,10 @@ const MobileMarketDetail: React.FC = () => { const longSkewText = useMemo(() => { return ( - marketInfo?.openInterest && + !!marketInfo && formatDollars(marketInfo.openInterest.longUSD, { maxDecimals: 2, - ...(marketInfo?.openInterest?.longUSD.gt(1e6) + ...(marketInfo?.openInterest.longUSD.gt(1e6) ? { truncation: { divisor: 1e6, unit: 'M' } } : {}), }) @@ -24,10 +24,10 @@ const MobileMarketDetail: React.FC = () => { const shortSkewText = useMemo(() => { return ( - marketInfo?.openInterest && + !!marketInfo && formatDollars(marketInfo.openInterest.shortUSD, { maxDecimals: 2, - ...(marketInfo?.openInterest?.shortUSD.gt(1e6) + ...(marketInfo?.openInterest.shortUSD.gt(1e6) ? { truncation: { divisor: 1e6, unit: 'M' } } : {}), }) @@ -39,13 +39,11 @@ const MobileMarketDetail: React.FC = () => {

Skew

- {marketInfo?.openInterest && - formatPercent(marketInfo.openInterest.longPct ?? 0, { minDecimals: 0 })}{' '} + {!!marketInfo && formatPercent(marketInfo.openInterest.longPct ?? 0, { minDecimals: 0 })}{' '} ({longSkewText})
- {marketInfo?.openInterest && - formatPercent(marketInfo.openInterest.shortPct ?? 0, { minDecimals: 0 })}{' '} + {!!marketInfo && formatPercent(marketInfo.openInterest.shortPct ?? 0, { minDecimals: 0 })}{' '} ({shortSkewText})
diff --git a/sections/futures/TradingHistory/SkewInfo.tsx b/sections/futures/TradingHistory/SkewInfo.tsx index 98836c1c5f..a4b07b218b 100644 --- a/sections/futures/TradingHistory/SkewInfo.tsx +++ b/sections/futures/TradingHistory/SkewInfo.tsx @@ -30,15 +30,15 @@ const SkewInfo: React.FC = () => { const data = useMemo(() => { return marketInfo?.openInterest ? { - short: marketInfo?.openInterest?.shortPct, - long: marketInfo?.openInterest?.longPct, - shortValue: marketInfo?.openInterest?.shortUSD, - longValue: marketInfo?.openInterest?.longUSD, - shortText: formatCurrency(marketAsset, marketInfo?.openInterest?.shortUSD, { + short: marketInfo?.openInterest.shortPct, + long: marketInfo?.openInterest.longPct, + shortValue: marketInfo?.openInterest.shortUSD, + longValue: marketInfo?.openInterest.longUSD, + shortText: formatCurrency(marketAsset, marketInfo?.openInterest.shortUSD, { sign: '$', minDecimals: 0, }), - longText: formatCurrency(marketAsset, marketInfo?.openInterest?.longUSD, { + longText: formatCurrency(marketAsset, marketInfo?.openInterest.longUSD, { sign: '$', minDecimals: 0, }), diff --git a/state/futures/selectors.ts b/state/futures/selectors.ts index 5a4cafe441..5068608b17 100644 --- a/state/futures/selectors.ts +++ b/state/futures/selectors.ts @@ -27,7 +27,7 @@ import { updatePositionUpnl, } from 'utils/futures'; -import { futuresPositionHistoryKeys, futuresPositionKeys } from './types'; +import { MarkPrices, futuresPositionHistoryKeys, futuresPositionKeys } from './types'; export const selectFuturesType = (state: RootState) => state.futures.selectedType; @@ -127,6 +127,19 @@ export const selectMarketPrices = createSelector( } ); +export const selectMarkPrices = createSelector(selectMarkets, selectPrices, (markets, prices) => { + const markPrices: MarkPrices = {}; + return markets.reduce((acc, market) => { + const price = prices[market.asset].offChain ?? wei(0); + return { + ...acc, + [market.marketKey]: wei(price).mul( + wei(market.marketSkew).div(market.settings.skewScale).add(1) + ), + }; + }, markPrices); +}); + export const selectFuturesAccount = createSelector( selectFuturesType, selectWallet, @@ -661,8 +674,7 @@ export const selectDelayedOrderFee = createSelector( export const selectOpenInterest = createSelector(selectMarkets, (futuresMarkets) => futuresMarkets.reduce( - (total, { openInterest }) => - total.add(openInterest?.shortUSD ?? wei(0)).add(openInterest?.longUSD ?? wei(0)), + (total, { openInterest }) => total.add(openInterest.shortUSD).add(openInterest.longUSD), wei(0) ) ); diff --git a/state/futures/types.ts b/state/futures/types.ts index d91eb5bc79..3bb8359a06 100644 --- a/state/futures/types.ts +++ b/state/futures/types.ts @@ -33,6 +33,8 @@ export type CrossMarginTradeInputsWithDelta = CrossMarginTradeInputs export type IsolatedMarginTradeInputs = TradeSizeInputs; +export type MarkPrices = Partial>; + export type FundingRateSerialized = { asset: FuturesMarketKey; fundingTitle: string; diff --git a/translations/en.json b/translations/en.json index 8860dc4aa2..3fd30f876e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -465,7 +465,7 @@ "futures-markets-table": { "market": "Market", "oracle": "Oracle", - "oracle-price": "Oracle Price", + "mark-price": "Mark Price", "daily-change": "24H Change", "funding-rate": "1H Funding Rate", "open-interest": "Open Interest", diff --git a/utils/futures.ts b/utils/futures.ts index a11a4ca752..512fdf536b 100644 --- a/utils/futures.ts +++ b/utils/futures.ts @@ -302,13 +302,11 @@ export const serializeMarket = (market: FuturesMarket): FuturesMarket => makerFeeOffchainDelayedOrder: market.feeRates.makerFeeOffchainDelayedOrder.toString(), takerFeeOffchainDelayedOrder: market.feeRates.takerFeeOffchainDelayedOrder.toString(), }, - openInterest: market.openInterest - ? { - ...market.openInterest, - shortUSD: market.openInterest.shortUSD.toString(), - longUSD: market.openInterest.longUSD.toString(), - } - : undefined, + openInterest: { + ...market.openInterest, + shortUSD: market.openInterest.shortUSD.toString(), + longUSD: market.openInterest.longUSD.toString(), + }, marketDebt: market.marketDebt.toString(), marketSkew: market.marketSkew.toString(), marketSize: market.marketSize.toString(), @@ -341,13 +339,11 @@ export const unserializeMarkets = (markets: FuturesMarket[]): FuturesMar makerFeeOffchainDelayedOrder: wei(m.feeRates.makerFeeOffchainDelayedOrder), takerFeeOffchainDelayedOrder: wei(m.feeRates.takerFeeOffchainDelayedOrder), }, - openInterest: m.openInterest - ? { - ...m.openInterest, - shortUSD: wei(m.openInterest.shortUSD), - longUSD: wei(m.openInterest.longUSD), - } - : undefined, + openInterest: { + ...m.openInterest, + shortUSD: wei(m.openInterest.shortUSD), + longUSD: wei(m.openInterest.longUSD), + }, marketDebt: wei(m.marketDebt), marketSkew: wei(m.marketSkew), marketSize: wei(m.marketSize),