Skip to content

Commit

Permalink
Merge branch 'main' into jv/bonsai-orderbook
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredvu committed Jan 24, 2025
2 parents 0aa0315 + dc94239 commit 7816298
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@dydxprotocol/v4-localization": "^1.1.259",
"@dydxprotocol/v4-proto": "^7.0.0-dev.0",
"@emotion/is-prop-valid": "^1.3.0",
"@funkit/connect": "^4.1.6",
"@funkit/connect": "^4.1.7",
"@hugocxl/react-to-image": "^0.0.9",
"@js-joda/core": "^5.5.3",
"@keplr-wallet/types": "^0.12.121",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/constants/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LEVERAGE_DECIMALS = 2;
export const TOKEN_DECIMALS = 4;
export const LARGE_TOKEN_DECIMALS = 2;
export const FEE_DECIMALS = 3;
export const FUNDING_DECIMALS = 4;
export const FUNDING_DECIMALS = 5;

export const QUANTUM_MULTIPLIER = 1_000_000;

Expand Down
11 changes: 7 additions & 4 deletions src/views/MarketStatsDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BonsaiCore, BonsaiHelpers } from '@/abacus-ts/ontology';
import styled, { css } from 'styled-components';

import { STRING_KEYS } from '@/constants/localization';
import { LARGE_TOKEN_DECIMALS, TINY_PERCENT_DECIMALS } from '@/constants/numbers';
import { FUNDING_DECIMALS, LARGE_TOKEN_DECIMALS } from '@/constants/numbers';
import { TooltipStringKeys } from '@/constants/tooltips';
import { DisplayUnit } from '@/constants/trade';

Expand All @@ -27,7 +27,7 @@ import { useAppSelector } from '@/state/appTypes';
import { getSelectedDisplayUnit } from '@/state/appUiConfigsSelectors';
import { getCurrentMarketMidMarketPrice } from '@/state/perpetualsSelectors';

import { BIG_NUMBERS, MustBigNumber } from '@/lib/numbers';
import { BIG_NUMBERS, MaybeBigNumber, MustBigNumber } from '@/lib/numbers';
import { orEmptyObj } from '@/lib/typeUtils';

import { MidMarketPrice } from './MidMarketPrice';
Expand Down Expand Up @@ -275,7 +275,7 @@ const DetailsItem = ({
type={OutputType.Percent}
value={value}
color={color}
fractionDigits={TINY_PERCENT_DECIMALS}
fractionDigits={FUNDING_DECIMALS}
/>
</WithTooltip>
);
Expand Down Expand Up @@ -319,7 +319,10 @@ const DetailsItem = ({
? BIG_NUMBERS.ONE.div(effectiveInitialMarginFraction)
: null
}
withDiff={initialMarginFraction !== effectiveInitialMarginFraction}
withDiff={
MaybeBigNumber(initialMarginFraction)?.toNumber() !==
(effectiveInitialMarginFraction ?? undefined)
}
type={OutputType.Multiple}
/>
);
Expand Down
2 changes: 2 additions & 0 deletions src/views/charts/FundingChart/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RenderTooltipParams } from '@visx/xychart/lib/components/Tooltip';
import { FundingRateResolution, type FundingChartDatum } from '@/constants/charts';
import { STRING_KEYS } from '@/constants/localization';
import { FundingDirection } from '@/constants/markets';
import { FUNDING_DECIMALS } from '@/constants/numbers';

import { useStringGetter } from '@/hooks/useStringGetter';

Expand Down Expand Up @@ -82,6 +83,7 @@ export const FundingChartTooltipContent = ({
value: (
<Output
type={OutputType.SmallPercent}
fractionDigits={FUNDING_DECIMALS}
value={
{
[FundingRateResolution.OneHour]: tooltipDatum?.fundingRate ?? 0,
Expand Down
7 changes: 4 additions & 3 deletions src/views/charts/FundingChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ButtonSize } from '@/constants/buttons';
import { FundingRateResolution, type FundingChartDatum } from '@/constants/charts';
import { STRING_KEYS } from '@/constants/localization';
import { FundingDirection } from '@/constants/markets';
import { SMALL_PERCENT_DECIMALS, TINY_PERCENT_DECIMALS } from '@/constants/numbers';
import { FUNDING_DECIMALS } from '@/constants/numbers';
import { timeUnits } from '@/constants/time';

import { useBreakpoints } from '@/hooks/useBreakpoints';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const FundingChart = ({ selectedLocale }: ElementProps) => {
},
]}
tickFormatY={(value) =>
`${(getAllFundingRates(value)[fundingRateView] * 100).toFixed(SMALL_PERCENT_DECIMALS)}%`
`${(getAllFundingRates(value)[fundingRateView] * 100).toFixed(FUNDING_DECIMALS)}%`
}
renderXAxisLabel={({ tooltipData }) => {
const tooltipDatum = tooltipData!.nearestDatum?.datum ?? latestDatum;
Expand All @@ -106,6 +106,7 @@ export const FundingChart = ({ selectedLocale }: ElementProps) => {
return (
<$YAxisLabelOutput
type={OutputType.SmallPercent}
fractionDigits={FUNDING_DECIMALS}
value={getAllFundingRates(tooltipDatum?.fundingRate)[fundingRateView]}
accentColor={
{
Expand Down Expand Up @@ -181,7 +182,7 @@ export const FundingChart = ({ selectedLocale }: ElementProps) => {
<$Output
type={OutputType.SmallPercent}
value={latestFundingRate}
fractionDigits={TINY_PERCENT_DECIMALS}
fractionDigits={FUNDING_DECIMALS}
isNegative={(latestFundingRate ?? 0) < 0}
/>
</$CurrentFundingRate>
Expand Down

0 comments on commit 7816298

Please sign in to comment.