Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a2cb2a296 | ||
|
|
ad6aa1af49 | ||
|
|
55b2c3fb4a | ||
|
|
83bcde00eb |
+2
-2
@@ -39,9 +39,9 @@
|
|||||||
"@cosmjs/proto-signing": "^0.31.0",
|
"@cosmjs/proto-signing": "^0.31.0",
|
||||||
"@cosmjs/stargate": "^0.31.0",
|
"@cosmjs/stargate": "^0.31.0",
|
||||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||||
"@dydxprotocol/v4-abacus": "^1.1.33",
|
"@dydxprotocol/v4-abacus": "^1.2.3",
|
||||||
"@dydxprotocol/v4-client-js": "^1.0.11",
|
"@dydxprotocol/v4-client-js": "^1.0.11",
|
||||||
"@dydxprotocol/v4-localization": "^1.1.6",
|
"@dydxprotocol/v4-localization": "^1.1.11",
|
||||||
"@ethersproject/providers": "^5.7.2",
|
"@ethersproject/providers": "^5.7.2",
|
||||||
"@js-joda/core": "^5.5.3",
|
"@js-joda/core": "^5.5.3",
|
||||||
"@radix-ui/react-accordion": "^1.1.2",
|
"@radix-ui/react-accordion": "^1.1.2",
|
||||||
|
|||||||
Generated
+8
-8
@@ -27,14 +27,14 @@ dependencies:
|
|||||||
specifier: ^0.31.0
|
specifier: ^0.31.0
|
||||||
version: 0.31.0
|
version: 0.31.0
|
||||||
'@dydxprotocol/v4-abacus':
|
'@dydxprotocol/v4-abacus':
|
||||||
specifier: ^1.1.33
|
specifier: ^1.2.3
|
||||||
version: 1.1.33
|
version: 1.2.3
|
||||||
'@dydxprotocol/v4-client-js':
|
'@dydxprotocol/v4-client-js':
|
||||||
specifier: ^1.0.11
|
specifier: ^1.0.11
|
||||||
version: 1.0.11
|
version: 1.0.11
|
||||||
'@dydxprotocol/v4-localization':
|
'@dydxprotocol/v4-localization':
|
||||||
specifier: ^1.1.6
|
specifier: ^1.1.11
|
||||||
version: 1.1.6
|
version: 1.1.11
|
||||||
'@ethersproject/providers':
|
'@ethersproject/providers':
|
||||||
specifier: ^5.7.2
|
specifier: ^5.7.2
|
||||||
version: 5.7.2
|
version: 5.7.2
|
||||||
@@ -991,8 +991,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@dydxprotocol/v4-abacus@1.1.33:
|
/@dydxprotocol/v4-abacus@1.2.3:
|
||||||
resolution: {integrity: sha512-VlIOaOPR4ImSWGmKK3+M4VHdMDdTk7qI77Iopppq11qU7f8wdwk4OeedTSuAMxezKez2nCP3J/x3Da+FtrKRqg==}
|
resolution: {integrity: sha512-OHGhN4uQo/ikRjeGzf+wGblFvb0uRA916QvQXG4LixsJy7H7HAt7AeZr9LqTM/GqYJicMmZCUS3WIMqgZ20hKA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-client-js@1.0.11:
|
/@dydxprotocol/v4-client-js@1.0.11:
|
||||||
@@ -1023,8 +1023,8 @@ packages:
|
|||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-localization@1.1.6:
|
/@dydxprotocol/v4-localization@1.1.11:
|
||||||
resolution: {integrity: sha512-Bon6NSRU4/FqneAbnP2G28EAPr0hp4LhvAayX61o0O1PGkxnLzAHkXeFppdM0Zn0fOcp1S1MJ+gvz138ZDephQ==}
|
resolution: {integrity: sha512-ZHnyrWD1bEpvY1tctkcmSV6A5+hQSYBFwyjbiyOqepqDqrv24J5a3hlZU94lDyYf+7Sdk3alOvy9Z7Lpk59nvw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-proto@0.4.1:
|
/@dydxprotocol/v4-proto@0.4.1:
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
CoinsIcon,
|
CoinsIcon,
|
||||||
CommentIcon,
|
CommentIcon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
CubeIcon,
|
|
||||||
DepositIcon,
|
DepositIcon,
|
||||||
DepthChartIcon,
|
DepthChartIcon,
|
||||||
DiscordIcon,
|
DiscordIcon,
|
||||||
@@ -99,7 +98,6 @@ export enum IconName {
|
|||||||
Coins = 'Coins',
|
Coins = 'Coins',
|
||||||
Comment = 'Comment',
|
Comment = 'Comment',
|
||||||
Copy = 'Copy',
|
Copy = 'Copy',
|
||||||
Cube = 'Cube',
|
|
||||||
Deposit = 'Deposit',
|
Deposit = 'Deposit',
|
||||||
DepthChart = 'DepthChart',
|
DepthChart = 'DepthChart',
|
||||||
Discord = 'Discord',
|
Discord = 'Discord',
|
||||||
@@ -175,7 +173,6 @@ const icons = {
|
|||||||
[IconName.Coins]: CoinsIcon,
|
[IconName.Coins]: CoinsIcon,
|
||||||
[IconName.Comment]: CommentIcon,
|
[IconName.Comment]: CommentIcon,
|
||||||
[IconName.Copy]: CopyIcon,
|
[IconName.Copy]: CopyIcon,
|
||||||
[IconName.Cube]: CubeIcon,
|
|
||||||
[IconName.Deposit]: DepositIcon,
|
[IconName.Deposit]: DepositIcon,
|
||||||
[IconName.DepthChart]: DepthChartIcon,
|
[IconName.DepthChart]: DepthChartIcon,
|
||||||
[IconName.Discord]: DiscordIcon,
|
[IconName.Discord]: DiscordIcon,
|
||||||
|
|||||||
@@ -1,26 +1,33 @@
|
|||||||
import React, { useContext, useState } from 'react';
|
import React, { PropsWithChildren, useContext, useState } from 'react';
|
||||||
|
|
||||||
import { Point } from '@visx/point';
|
import { Point } from '@visx/point';
|
||||||
import { localPoint } from '@visx/event';
|
import { localPoint } from '@visx/event';
|
||||||
import { XYChart, DataContext } from '@visx/xychart';
|
import { XYChart, DataContext, type EventHandlerParams } from '@visx/xychart';
|
||||||
import { getScaleBandwidth } from '@/components/visx/getScaleBandwidth';
|
import { getScaleBandwidth } from '@/components/visx/getScaleBandwidth';
|
||||||
|
|
||||||
export const XYChartWithPointerEvents = ({
|
export const XYChartWithPointerEvents = ({
|
||||||
onPointerMove, onPointerUp, onPointerPressedChange, ...props
|
onPointerMove,
|
||||||
|
onPointerUp,
|
||||||
|
onPointerPressedChange,
|
||||||
|
...props
|
||||||
}: {
|
}: {
|
||||||
onPointerMove?: (point: Point) => void;
|
onPointerMove?: (point: Point | EventHandlerParams<object>) => void;
|
||||||
onPointerUp?: (point: Point) => void;
|
onPointerUp?: (point: Point | EventHandlerParams<object>) => void;
|
||||||
onPointerPressedChange?: (isPointerPressed: boolean) => void;
|
onPointerPressedChange?: (isPointerPressed: boolean) => void;
|
||||||
} & React.PropsWithChildren<Parameters<typeof XYChart>>) => {
|
} & PropsWithChildren<Parameters<typeof XYChart>[0]>) => {
|
||||||
const { xScale, yScale } = useContext(DataContext);
|
const { xScale, yScale } = useContext(DataContext);
|
||||||
|
|
||||||
const [lastPointerMoveEvent, setLastPointerMoveEvent] = useState<React.PointerEvent>();
|
const [lastPointerMoveEvent, setLastPointerMoveEvent] = useState<React.PointerEvent>();
|
||||||
|
|
||||||
const pointerContainerPosition = lastPointerMoveEvent ? localPoint(lastPointerMoveEvent) : null;
|
const pointerContainerPosition = lastPointerMoveEvent ? localPoint(lastPointerMoveEvent) : null;
|
||||||
|
|
||||||
const pointerChartPosition = xScale && yScale && pointerContainerPosition &&
|
const pointerChartPosition =
|
||||||
|
xScale &&
|
||||||
|
yScale &&
|
||||||
|
pointerContainerPosition &&
|
||||||
new Point({
|
new Point({
|
||||||
|
// @ts-expect-error invert supposedly doesn't exist on AxisScale
|
||||||
x: xScale.invert(pointerContainerPosition?.x - getScaleBandwidth(xScale) / 2),
|
x: xScale.invert(pointerContainerPosition?.x - getScaleBandwidth(xScale) / 2),
|
||||||
|
// @ts-expect-error invert supposedly doesn't exist on AxisScale
|
||||||
y: yScale.invert(pointerContainerPosition?.y - getScaleBandwidth(yScale) / 2),
|
y: yScale.invert(pointerContainerPosition?.y - getScaleBandwidth(yScale) / 2),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -29,15 +36,13 @@ export const XYChartWithPointerEvents = ({
|
|||||||
{...props}
|
{...props}
|
||||||
onPointerMove={({ event }) => {
|
onPointerMove={({ event }) => {
|
||||||
setLastPointerMoveEvent(event as React.PointerEvent);
|
setLastPointerMoveEvent(event as React.PointerEvent);
|
||||||
if (pointerChartPosition)
|
if (pointerChartPosition) onPointerMove?.(pointerChartPosition);
|
||||||
onPointerMove?.(pointerChartPosition);
|
|
||||||
}}
|
}}
|
||||||
onPointerOut={() => setLastPointerMoveEvent(undefined)}
|
onPointerOut={() => setLastPointerMoveEvent(undefined)}
|
||||||
onPointerDown={() => onPointerPressedChange?.(true)}
|
onPointerDown={() => onPointerPressedChange?.(true)}
|
||||||
onPointerUp={() => {
|
onPointerUp={() => {
|
||||||
onPointerPressedChange?.(false);
|
onPointerPressedChange?.(false);
|
||||||
if (pointerChartPosition)
|
if (pointerChartPosition) onPointerUp?.(pointerChartPosition);
|
||||||
onPointerUp?.(pointerChartPosition);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ const historicalPnlPeriod = [...HistoricalPnlPeriod.values()] as const;
|
|||||||
export type HistoricalPnlPeriods = (typeof historicalPnlPeriod)[number];
|
export type HistoricalPnlPeriods = (typeof historicalPnlPeriod)[number];
|
||||||
|
|
||||||
// ------ Transfer Items ------ //
|
// ------ Transfer Items ------ //
|
||||||
export const TransferInputField = Abacus.exchange.dydx.abacus.state.modal.TransferInputField;
|
export const TransferInputField = Abacus.exchange.dydx.abacus.state.model.TransferInputField;
|
||||||
const transferInputFields = [...TransferInputField.values()] as const;
|
const transferInputFields = [...TransferInputField.values()] as const;
|
||||||
export type TransferInputFields = (typeof transferInputFields)[number];
|
export type TransferInputFields = (typeof transferInputFields)[number];
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ const transferTypes = [...TransferType.values()] as const;
|
|||||||
export type TransferTypes = (typeof transferTypes)[number];
|
export type TransferTypes = (typeof transferTypes)[number];
|
||||||
|
|
||||||
// ------ Trade Items ------ //
|
// ------ Trade Items ------ //
|
||||||
export const TradeInputField = Abacus.exchange.dydx.abacus.state.modal.TradeInputField;
|
export const TradeInputField = Abacus.exchange.dydx.abacus.state.model.TradeInputField;
|
||||||
const tradeInputFields = [...TradeInputField.values()] as const;
|
const tradeInputFields = [...TradeInputField.values()] as const;
|
||||||
export type TradeInputFields = (typeof tradeInputFields)[number];
|
export type TradeInputFields = (typeof tradeInputFields)[number];
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ export type TradeState<T> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ClosePositionInputField =
|
export const ClosePositionInputField =
|
||||||
Abacus.exchange.dydx.abacus.state.modal.ClosePositionInputField;
|
Abacus.exchange.dydx.abacus.state.model.ClosePositionInputField;
|
||||||
|
|
||||||
const closePositionInputFields = [...ClosePositionInputField.values()] as const;
|
const closePositionInputFields = [...ClosePositionInputField.values()] as const;
|
||||||
export type ClosePositionInputFields = (typeof closePositionInputFields)[number];
|
export type ClosePositionInputFields = (typeof closePositionInputFields)[number];
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export type AnalyticsEventData<T extends AnalyticsEvent> =
|
|||||||
elapsedTime?: number;
|
elapsedTime?: number;
|
||||||
blockHeight?: number;
|
blockHeight?: number;
|
||||||
indexerBlockHeight?: number;
|
indexerBlockHeight?: number;
|
||||||
|
trailingBlocks?: number;
|
||||||
}
|
}
|
||||||
: // Navigation
|
: // Navigation
|
||||||
T extends AnalyticsEvent.NavigatePage
|
T extends AnalyticsEvent.NavigatePage
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
import { FundingDirection } from './markets';
|
||||||
|
|
||||||
|
// ------ Depth Chart ------ //
|
||||||
|
export enum DepthChartSeries {
|
||||||
|
Asks = 'Asks',
|
||||||
|
Bids = 'Bids',
|
||||||
|
MidMarket = 'MidMarket',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DepthChartDatum = {
|
||||||
|
size: number;
|
||||||
|
price: number;
|
||||||
|
depth: number;
|
||||||
|
seriesKey: DepthChartSeries;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DepthChartPoint = {
|
||||||
|
side: OrderSide;
|
||||||
|
price: number;
|
||||||
|
size: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SERIES_KEY_FOR_ORDER_SIDE = {
|
||||||
|
[OrderSide.BUY]: DepthChartSeries.Bids,
|
||||||
|
[OrderSide.SELL]: DepthChartSeries.Asks,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------ Funding Chart ------ //
|
||||||
|
export enum FundingRateResolution {
|
||||||
|
OneHour = 'OneHour',
|
||||||
|
EightHour = 'EightHour',
|
||||||
|
Annualized = 'Annualized',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FundingChartDatum = {
|
||||||
|
time: number;
|
||||||
|
fundingRate: number;
|
||||||
|
direction: FundingDirection;
|
||||||
|
};
|
||||||
@@ -25,4 +25,5 @@ export const DEFAULT_MARKETID = 'ETH-USD';
|
|||||||
export enum FundingDirection {
|
export enum FundingDirection {
|
||||||
ToShort = 'ToShort',
|
ToShort = 'ToShort',
|
||||||
ToLong = 'ToLong',
|
ToLong = 'ToLong',
|
||||||
|
None = 'None',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export const useAnalytics = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// AnalyticsEvent.NetworkStatus
|
// AnalyticsEvent.NetworkStatus
|
||||||
const { height, indexerHeight, status } = useApiState();
|
const { height, indexerHeight, status, trailingBlocks} = useApiState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status) {
|
if (status) {
|
||||||
@@ -114,6 +114,7 @@ export const useAnalytics = () => {
|
|||||||
elapsedTime: lastSuccessfulIndexerRpcQuery && Date.now() - lastSuccessfulIndexerRpcQuery,
|
elapsedTime: lastSuccessfulIndexerRpcQuery && Date.now() - lastSuccessfulIndexerRpcQuery,
|
||||||
blockHeight: height ?? undefined,
|
blockHeight: height ?? undefined,
|
||||||
indexerBlockHeight: indexerHeight ?? undefined,
|
indexerBlockHeight: indexerHeight ?? undefined,
|
||||||
|
trailingBlocks: trailingBlocks ?? undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [status]);
|
}, [status]);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const getIndexerHeight = (apiState: Nullable<AbacusApiState>) => {
|
|||||||
export const useApiState = () => {
|
export const useApiState = () => {
|
||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
const apiState = useSelector(getApiState, shallowEqual);
|
const apiState = useSelector(getApiState, shallowEqual);
|
||||||
const { haltedBlock, height, status, trailingBlocks } = apiState ?? {};
|
const { haltedBlock, height, status, trailingBlocks} = apiState ?? {};
|
||||||
const statusErrorMessage = getStatusErrorMessage({ apiState, stringGetter });
|
const statusErrorMessage = getStatusErrorMessage({ apiState, stringGetter });
|
||||||
const indexerHeight = getIndexerHeight(apiState);
|
const indexerHeight = getIndexerHeight(apiState);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { useMemo } from 'react';
|
||||||
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
|
|
||||||
|
import { DepthChartSeries, DepthChartDatum } from '@/constants/charts';
|
||||||
|
|
||||||
|
import { getCurrentMarketOrderbook } from '@/state/perpetualsSelectors';
|
||||||
|
|
||||||
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
|
|
||||||
|
export const useOrderbookValuesForDepthChart = () => {
|
||||||
|
const orderbook = useSelector(getCurrentMarketOrderbook, shallowEqual);
|
||||||
|
|
||||||
|
return useMemo(() => {
|
||||||
|
const bids = (orderbook?.bids?.toArray() ?? [])
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((datum) => ({ ...datum, seriesKey: DepthChartSeries.Bids } as DepthChartDatum));
|
||||||
|
|
||||||
|
const asks = (orderbook?.asks?.toArray() ?? [])
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((datum) => ({ ...datum, seriesKey: DepthChartSeries.Asks } as DepthChartDatum));
|
||||||
|
|
||||||
|
const lowestBid = bids[bids.length - 1];
|
||||||
|
const highestBid = bids[0];
|
||||||
|
const lowestAsk = asks[0];
|
||||||
|
const highestAsk = asks[asks.length - 1];
|
||||||
|
|
||||||
|
const midMarketPrice = orderbook?.midPrice;
|
||||||
|
const spread = MustBigNumber(lowestAsk?.price ?? 0).minus(highestBid?.price ?? 0);
|
||||||
|
const spreadPercent = orderbook?.spreadPercent;
|
||||||
|
|
||||||
|
return {
|
||||||
|
bids,
|
||||||
|
asks,
|
||||||
|
lowestBid,
|
||||||
|
highestBid,
|
||||||
|
lowestAsk,
|
||||||
|
highestAsk,
|
||||||
|
midMarketPrice,
|
||||||
|
spread,
|
||||||
|
spreadPercent,
|
||||||
|
orderbook,
|
||||||
|
};
|
||||||
|
}, [orderbook]);
|
||||||
|
};
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M7.95513 1.00169C7.89506 1.00645 7.83628 1.02054 7.78124 1.04337L1.31971 3.71042C1.2243 3.74983 1.14329 3.81414 1.08653 3.89553C1.02977 3.97691 0.999705 4.07186 1 4.16883V11.8366C1.00078 11.9327 1.03135 12.0265 1.08805 12.1069C1.14474 12.1873 1.22517 12.2508 1.31971 12.2898L7.78124 14.9568C7.85011 14.9853 7.92463 15 8 15C8.07536 15 8.14989 14.9853 8.21876 14.9568L14.6803 12.2898C14.7748 12.2508 14.8552 12.1873 14.9119 12.1069C14.9686 12.0265 14.9992 11.9327 15 11.8366V4.16883C15.0003 4.07186 14.9702 3.97691 14.9134 3.89553C14.8567 3.81414 14.7756 3.74983 14.6803 3.71042L8.21876 1.04337C8.13605 1.00911 8.04538 0.994778 7.95513 1.00169ZM8 2.04351L13.1378 4.16883L8 6.28894L2.86219 4.16883L8 2.04351ZM2.07693 4.93457L7.46153 7.15886V13.7328L2.07693 11.5084V4.93457ZM13.923 4.93457V11.5084L8.53846 13.7328V7.15886L13.923 4.93457Z" fill="currentColor"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 969 B |
@@ -19,7 +19,6 @@ export { default as CoinMarketCapIcon } from './logos/coinmarketcap.svg';
|
|||||||
export { default as CoinsIcon } from './coins.svg';
|
export { default as CoinsIcon } from './coins.svg';
|
||||||
export { default as CommentIcon } from './comment.svg';
|
export { default as CommentIcon } from './comment.svg';
|
||||||
export { default as CopyIcon } from './copy.svg';
|
export { default as CopyIcon } from './copy.svg';
|
||||||
export { default as CubeIcon } from './cube.svg';
|
|
||||||
export { default as DepositIcon } from './deposit.svg';
|
export { default as DepositIcon } from './deposit.svg';
|
||||||
export { default as DepthChartIcon } from './depth-chart.svg';
|
export { default as DepthChartIcon } from './depth-chart.svg';
|
||||||
export { default as DiscordIcon } from './discord.svg';
|
export { default as DiscordIcon } from './discord.svg';
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: PortfolioRoute.Positions,
|
value: PortfolioRoute.Positions,
|
||||||
slotBefore: <Styled.Icon iconName={IconName.Cube} />,
|
slotBefore: <Styled.Icon iconName={IconName.Positions} />,
|
||||||
label: stringGetter({ key: STRING_KEYS.POSITIONS }),
|
label: stringGetter({ key: STRING_KEYS.POSITIONS }),
|
||||||
href: PortfolioRoute.Positions,
|
href: PortfolioRoute.Positions,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ export const calculateFundingRateHistory = createSelector(
|
|||||||
return data.map(({ effectiveAtMilliseconds, rate }) => ({
|
return data.map(({ effectiveAtMilliseconds, rate }) => ({
|
||||||
time: effectiveAtMilliseconds,
|
time: effectiveAtMilliseconds,
|
||||||
fundingRate: rate,
|
fundingRate: rate,
|
||||||
direction: rate < 0 ? FundingDirection.ToLong : FundingDirection.ToShort,
|
direction:
|
||||||
|
rate === 0
|
||||||
|
? FundingDirection.None
|
||||||
|
: rate < 0
|
||||||
|
? FundingDirection.ToLong
|
||||||
|
: FundingDirection.ToShort,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,220 @@
|
|||||||
|
import { useMemo } from 'react';
|
||||||
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
import type { RenderTooltipParams } from '@visx/xychart/lib/components/Tooltip';
|
||||||
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
|
|
||||||
|
import type { Nullable } from '@/constants/abacus';
|
||||||
|
import {
|
||||||
|
DepthChartDatum,
|
||||||
|
DepthChartPoint,
|
||||||
|
DepthChartSeries,
|
||||||
|
SERIES_KEY_FOR_ORDER_SIDE,
|
||||||
|
} from '@/constants/charts';
|
||||||
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
|
||||||
|
import { useStringGetter } from '@/hooks';
|
||||||
|
import { useOrderbookValuesForDepthChart } from '@/hooks/useOrderbookValues';
|
||||||
|
|
||||||
|
import { TooltipContent } from '@/components/visx/TooltipContent';
|
||||||
|
import { Details } from '@/components/Details';
|
||||||
|
import { Output, OutputType } from '@/components/Output';
|
||||||
|
|
||||||
|
import { getCurrentMarketAssetData } from '@/state/assetsSelectors';
|
||||||
|
|
||||||
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
|
|
||||||
|
type DepthChartTooltipProps = {
|
||||||
|
chartPointAtPointer: DepthChartPoint;
|
||||||
|
isEditingOrder?: boolean;
|
||||||
|
stepSizeDecimals: Nullable<number>;
|
||||||
|
tickSizeDecimals: Nullable<number>;
|
||||||
|
} & Pick<RenderTooltipParams<DepthChartDatum>, 'colorScale' | 'tooltipData'>;
|
||||||
|
|
||||||
|
export const DepthChartTooltipContent = ({
|
||||||
|
chartPointAtPointer,
|
||||||
|
colorScale,
|
||||||
|
isEditingOrder,
|
||||||
|
stepSizeDecimals,
|
||||||
|
tickSizeDecimals,
|
||||||
|
tooltipData,
|
||||||
|
}: DepthChartTooltipProps) => {
|
||||||
|
const { nearestDatum } = tooltipData || {};
|
||||||
|
const stringGetter = useStringGetter();
|
||||||
|
const { spread, spreadPercent, midMarketPrice } = useOrderbookValuesForDepthChart();
|
||||||
|
const { id = '' } = useSelector(getCurrentMarketAssetData, shallowEqual) ?? {};
|
||||||
|
|
||||||
|
const priceImpact = useMemo(() => {
|
||||||
|
if (nearestDatum) {
|
||||||
|
const depthChartSeries = nearestDatum.key as DepthChartSeries;
|
||||||
|
|
||||||
|
return {
|
||||||
|
[DepthChartSeries.Bids]: MustBigNumber(nearestDatum?.datum.price)
|
||||||
|
.minus(chartPointAtPointer.price)
|
||||||
|
.div(nearestDatum?.datum.price),
|
||||||
|
[DepthChartSeries.Asks]: MustBigNumber(chartPointAtPointer.price)
|
||||||
|
.minus(nearestDatum?.datum.price)
|
||||||
|
.div(chartPointAtPointer.price),
|
||||||
|
[DepthChartSeries.MidMarket]: undefined,
|
||||||
|
}[depthChartSeries];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}, [nearestDatum, chartPointAtPointer.price]);
|
||||||
|
|
||||||
|
if (!isEditingOrder && !nearestDatum?.datum) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TooltipContent
|
||||||
|
accentColor={
|
||||||
|
nearestDatum?.key &&
|
||||||
|
colorScale?.(
|
||||||
|
isEditingOrder ? SERIES_KEY_FOR_ORDER_SIDE[chartPointAtPointer.side] : nearestDatum.key
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<h4>
|
||||||
|
{isEditingOrder
|
||||||
|
? stringGetter({ key: STRING_KEYS.RELEASE_TO_EDIT })
|
||||||
|
: nearestDatum &&
|
||||||
|
{
|
||||||
|
[DepthChartSeries.Bids]: stringGetter({ key: STRING_KEYS.BIDS }),
|
||||||
|
[DepthChartSeries.Asks]: stringGetter({ key: STRING_KEYS.ASKS }),
|
||||||
|
[DepthChartSeries.MidMarket]: stringGetter({ key: STRING_KEYS.MID_MARKET }),
|
||||||
|
}[nearestDatum.key]}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<Details
|
||||||
|
layout="column"
|
||||||
|
items={
|
||||||
|
isEditingOrder
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
key: 'side',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.SIDE }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.Text}
|
||||||
|
value={
|
||||||
|
{
|
||||||
|
[OrderSide.BUY]: stringGetter({
|
||||||
|
key: STRING_KEYS.BUY,
|
||||||
|
}),
|
||||||
|
[OrderSide.SELL]: stringGetter({
|
||||||
|
key: STRING_KEYS.SELL,
|
||||||
|
}),
|
||||||
|
}[chartPointAtPointer.side]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'limitPrice',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.LIMIT_PRICE }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.Fiat}
|
||||||
|
value={chartPointAtPointer.price}
|
||||||
|
useGrouping={false}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'size',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.AMOUNT }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.Asset}
|
||||||
|
value={chartPointAtPointer.size}
|
||||||
|
fractionDigits={stepSizeDecimals}
|
||||||
|
tag={id}
|
||||||
|
useGrouping={false}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: nearestDatum?.key === DepthChartSeries.MidMarket
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
key: 'midMarketPrice',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.PRICE }),
|
||||||
|
value: (
|
||||||
|
<Output type={OutputType.Fiat} value={midMarketPrice} useGrouping={false} />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'spread',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.ORDERBOOK_SPREAD }),
|
||||||
|
value: (
|
||||||
|
<>
|
||||||
|
<Output
|
||||||
|
type={OutputType.Fiat}
|
||||||
|
value={spread}
|
||||||
|
fractionDigits={tickSizeDecimals}
|
||||||
|
useGrouping={false}
|
||||||
|
/>
|
||||||
|
<Output
|
||||||
|
type={OutputType.SmallPercent}
|
||||||
|
value={spreadPercent}
|
||||||
|
withParentheses
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
key: 'price',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.PRICE }),
|
||||||
|
value: (
|
||||||
|
<>
|
||||||
|
{nearestDatum &&
|
||||||
|
{
|
||||||
|
[DepthChartSeries.Bids]: '≥',
|
||||||
|
[DepthChartSeries.Asks]: '≤',
|
||||||
|
}[nearestDatum.key]}
|
||||||
|
<Output
|
||||||
|
type={OutputType.Fiat}
|
||||||
|
value={nearestDatum?.datum.price}
|
||||||
|
useGrouping={false}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'depth',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.TOTAL_SIZE }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.Asset}
|
||||||
|
value={nearestDatum?.datum.depth}
|
||||||
|
fractionDigits={stepSizeDecimals}
|
||||||
|
tag={id}
|
||||||
|
useGrouping={false}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'cost',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.TOTAL_COST }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
useGrouping
|
||||||
|
type={OutputType.Fiat}
|
||||||
|
value={
|
||||||
|
nearestDatum
|
||||||
|
? nearestDatum?.datum.price * nearestDatum?.datum.depth
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'priceImpact',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.PRICE_IMPACT }),
|
||||||
|
value: <Output useGrouping type={OutputType.Percent} value={priceImpact} />,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</TooltipContent>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,14 +1,20 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import styled, { AnyStyledComponent, css, keyframes } from 'styled-components';
|
import styled, { AnyStyledComponent, css, keyframes } from 'styled-components';
|
||||||
import { useSelector, shallowEqual } from 'react-redux';
|
import { useSelector, shallowEqual } from 'react-redux';
|
||||||
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { StringGetterFunction, STRING_KEYS } from '@/constants/localization';
|
import {
|
||||||
|
DepthChartDatum,
|
||||||
|
DepthChartPoint,
|
||||||
|
DepthChartSeries,
|
||||||
|
SERIES_KEY_FOR_ORDER_SIDE,
|
||||||
|
} from '@/constants/charts';
|
||||||
|
import { StringGetterFunction } from '@/constants/localization';
|
||||||
|
|
||||||
import { useBreakpoints } from '@/hooks';
|
import { useBreakpoints } from '@/hooks';
|
||||||
|
import { useOrderbookValuesForDepthChart } from '@/hooks/useOrderbookValues';
|
||||||
|
|
||||||
import { MustBigNumber } from '@/lib/numbers';
|
import { getCurrentMarketConfig } from '@/state/perpetualsSelectors';
|
||||||
|
|
||||||
import { getCurrentMarketConfig, getCurrentMarketOrderbook } from '@/state/perpetualsSelectors';
|
|
||||||
import { getCurrentMarketAssetData } from '@/state/assetsSelectors';
|
import { getCurrentMarketAssetData } from '@/state/assetsSelectors';
|
||||||
|
|
||||||
import { XYChartWithPointerEvents } from '@/components/visx/XYChartWithPointerEvents';
|
import { XYChartWithPointerEvents } from '@/components/visx/XYChartWithPointerEvents';
|
||||||
@@ -21,24 +27,25 @@ import {
|
|||||||
darkTheme,
|
darkTheme,
|
||||||
DataProvider,
|
DataProvider,
|
||||||
EventEmitterProvider,
|
EventEmitterProvider,
|
||||||
|
type EventHandlerParams,
|
||||||
} from '@visx/xychart';
|
} from '@visx/xychart';
|
||||||
import { LinearGradient } from '@visx/gradient';
|
import { LinearGradient } from '@visx/gradient';
|
||||||
import { curveStepAfter } from '@visx/curve';
|
import { curveStepAfter } from '@visx/curve';
|
||||||
import type { Point } from '@visx/point';
|
import { Point } from '@visx/point';
|
||||||
import Tooltip from '@/components/visx/XYChartTooltipWithBounds';
|
import Tooltip from '@/components/visx/XYChartTooltipWithBounds';
|
||||||
import { TooltipContent } from '@/components/visx/TooltipContent';
|
|
||||||
import { AxisLabelOutput } from '@/components/visx/AxisLabelOutput';
|
import { AxisLabelOutput } from '@/components/visx/AxisLabelOutput';
|
||||||
|
|
||||||
import { Details } from '@/components/Details';
|
|
||||||
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
||||||
import { Output, OutputType } from '@/components/Output';
|
import { OutputType } from '@/components/Output';
|
||||||
|
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
|
|
||||||
|
import { DepthChartTooltipContent } from './Tooltip';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const theme = buildChartTheme({
|
const theme = buildChartTheme({
|
||||||
...darkTheme,
|
...darkTheme,
|
||||||
colors: ['var(--color-positive)', 'var(--color-negative)', 'white'], // categorical colors, mapped to series via `dataKey`s
|
colors: ['var(--color-positive)', 'var(--color-negative)', 'var(--color-layer-6)'], // categorical colors, mapped to series via `dataKey`s
|
||||||
});
|
});
|
||||||
|
|
||||||
const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));
|
const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));
|
||||||
@@ -58,30 +65,6 @@ const formatNumber = (n: number, selectedLocale: string, isCompact: boolean = n
|
|||||||
: formattedNumber;
|
: formattedNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DepthChartSeries {
|
|
||||||
Asks = 'Asks',
|
|
||||||
Bids = 'Bids',
|
|
||||||
MidMarket = 'MidMarket',
|
|
||||||
}
|
|
||||||
|
|
||||||
type DepthChartDatum = {
|
|
||||||
size: number;
|
|
||||||
price: number;
|
|
||||||
depth: number;
|
|
||||||
seriesKey: DepthChartSeries;
|
|
||||||
};
|
|
||||||
|
|
||||||
const seriesKeyForOrderSide = {
|
|
||||||
[OrderSide.BUY]: DepthChartSeries.Bids,
|
|
||||||
[OrderSide.SELL]: DepthChartSeries.Asks,
|
|
||||||
};
|
|
||||||
|
|
||||||
type DepthChartPoint = {
|
|
||||||
side: OrderSide;
|
|
||||||
price: number;
|
|
||||||
size: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DepthChart = ({
|
export const DepthChart = ({
|
||||||
onChartClick,
|
onChartClick,
|
||||||
stringGetter,
|
stringGetter,
|
||||||
@@ -96,8 +79,6 @@ export const DepthChart = ({
|
|||||||
const { isMobile } = useBreakpoints();
|
const { isMobile } = useBreakpoints();
|
||||||
|
|
||||||
// Chart data
|
// Chart data
|
||||||
|
|
||||||
const orderbook = useSelector(getCurrentMarketOrderbook, shallowEqual);
|
|
||||||
const { id = '' } = useSelector(getCurrentMarketAssetData, shallowEqual) ?? {};
|
const { id = '' } = useSelector(getCurrentMarketAssetData, shallowEqual) ?? {};
|
||||||
const { stepSizeDecimals, tickSizeDecimals } =
|
const { stepSizeDecimals, tickSizeDecimals } =
|
||||||
useSelector(getCurrentMarketConfig, shallowEqual) ?? {};
|
useSelector(getCurrentMarketConfig, shallowEqual) ?? {};
|
||||||
@@ -112,43 +93,15 @@ export const DepthChart = ({
|
|||||||
midMarketPrice,
|
midMarketPrice,
|
||||||
spread,
|
spread,
|
||||||
spreadPercent,
|
spreadPercent,
|
||||||
} = useMemo(() => {
|
orderbook,
|
||||||
const bids = (orderbook?.bids?.toArray() ?? [])
|
} = useOrderbookValuesForDepthChart();
|
||||||
.filter(Boolean)
|
|
||||||
.map((datum) => ({ ...datum, seriesKey: DepthChartSeries.Bids } as DepthChartDatum));
|
|
||||||
|
|
||||||
const asks = (orderbook?.asks?.toArray() ?? [])
|
|
||||||
.filter(Boolean)
|
|
||||||
.map((datum) => ({ ...datum, seriesKey: DepthChartSeries.Asks } as DepthChartDatum));
|
|
||||||
|
|
||||||
const lowestBid = bids[bids.length - 1];
|
|
||||||
const highestBid = bids[0];
|
|
||||||
const lowestAsk = asks[0];
|
|
||||||
const highestAsk = asks[asks.length - 1];
|
|
||||||
|
|
||||||
const midMarketPrice = orderbook?.midPrice;
|
|
||||||
const spread = MustBigNumber(lowestAsk?.price ?? 0).minus(highestBid?.price ?? 0);
|
|
||||||
const spreadPercent = orderbook?.spreadPercent;
|
|
||||||
|
|
||||||
return {
|
|
||||||
bids,
|
|
||||||
asks,
|
|
||||||
lowestBid,
|
|
||||||
highestBid,
|
|
||||||
lowestAsk,
|
|
||||||
highestAsk,
|
|
||||||
midMarketPrice,
|
|
||||||
spread,
|
|
||||||
spreadPercent,
|
|
||||||
};
|
|
||||||
}, [orderbook]);
|
|
||||||
|
|
||||||
// Chart state
|
// Chart state
|
||||||
|
|
||||||
const [isPointerPressed, setIsPointerPressed] = useState(false);
|
const [isPointerPressed, setIsPointerPressed] = useState(false);
|
||||||
const [chartPointAtPointer, setChartPointAtPointer] = useState<DepthChartPoint>();
|
const [chartPointAtPointer, setChartPointAtPointer] = useState<DepthChartPoint>();
|
||||||
|
|
||||||
const isEditingOrder = isPointerPressed && chartPointAtPointer;
|
const isEditingOrder = Boolean(isPointerPressed && chartPointAtPointer);
|
||||||
|
|
||||||
const [zoomDomain, setZoomDomain] = useState<undefined | number>();
|
const [zoomDomain, setZoomDomain] = useState<undefined | number>();
|
||||||
|
|
||||||
@@ -193,12 +146,24 @@ export const DepthChart = ({
|
|||||||
}, [orderbook, zoomDomain]);
|
}, [orderbook, zoomDomain]);
|
||||||
|
|
||||||
const getChartPoint = useCallback(
|
const getChartPoint = useCallback(
|
||||||
({ x: price, y: size }: Point) =>
|
(point: Point | EventHandlerParams<object>) => {
|
||||||
({
|
let price, size;
|
||||||
side: price < midMarketPrice! ? OrderSide.BUY : OrderSide.SELL,
|
if (point instanceof Point) {
|
||||||
|
const { x, y } = point as Point;
|
||||||
|
price = x;
|
||||||
|
size = y;
|
||||||
|
} else {
|
||||||
|
const { svgPoint: { x, y } = {} } = point as EventHandlerParams<object>;
|
||||||
|
price = x;
|
||||||
|
size = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
side: MustBigNumber(price).lt(midMarketPrice!) ? OrderSide.BUY : OrderSide.SELL,
|
||||||
price,
|
price,
|
||||||
size,
|
size,
|
||||||
} as DepthChartPoint),
|
} as DepthChartPoint;
|
||||||
|
},
|
||||||
[midMarketPrice]
|
[midMarketPrice]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -256,7 +221,7 @@ export const DepthChart = ({
|
|||||||
}}
|
}}
|
||||||
onPointerUp={(point) => point && onChartClick?.(getChartPoint(point))}
|
onPointerUp={(point) => point && onChartClick?.(getChartPoint(point))}
|
||||||
onPointerMove={(point) => point && setChartPointAtPointer(getChartPoint(point))}
|
onPointerMove={(point) => point && setChartPointAtPointer(getChartPoint(point))}
|
||||||
onPointerPressedChange={setIsPointerPressed}
|
onPointerPressedChange={(isPointerPressed) => setIsPointerPressed(isPointerPressed)}
|
||||||
>
|
>
|
||||||
<Axis
|
<Axis
|
||||||
orientation="bottom"
|
orientation="bottom"
|
||||||
@@ -363,7 +328,7 @@ export const DepthChart = ({
|
|||||||
<Styled.XAxisLabelOutput
|
<Styled.XAxisLabelOutput
|
||||||
type={OutputType.Fiat}
|
type={OutputType.Fiat}
|
||||||
value={
|
value={
|
||||||
isEditingOrder
|
isEditingOrder && chartPointAtPointer
|
||||||
? chartPointAtPointer.price
|
? chartPointAtPointer.price
|
||||||
: tooltipData!.nearestDatum?.datum.price
|
: tooltipData!.nearestDatum?.datum.price
|
||||||
}
|
}
|
||||||
@@ -374,8 +339,8 @@ export const DepthChart = ({
|
|||||||
[DepthChartSeries.Bids]: 'var(--color-positive)',
|
[DepthChartSeries.Bids]: 'var(--color-positive)',
|
||||||
[DepthChartSeries.MidMarket]: 'var(--color-layer-6)',
|
[DepthChartSeries.MidMarket]: 'var(--color-layer-6)',
|
||||||
}[
|
}[
|
||||||
isEditingOrder
|
isEditingOrder && chartPointAtPointer
|
||||||
? seriesKeyForOrderSide[chartPointAtPointer.side]
|
? SERIES_KEY_FOR_ORDER_SIDE[chartPointAtPointer.side]
|
||||||
: (tooltipData!.nearestDatum?.key as DepthChartSeries)
|
: (tooltipData!.nearestDatum?.key as DepthChartSeries)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -389,7 +354,7 @@ export const DepthChart = ({
|
|||||||
<Styled.YAxisLabelOutput
|
<Styled.YAxisLabelOutput
|
||||||
type={OutputType.Asset}
|
type={OutputType.Asset}
|
||||||
value={
|
value={
|
||||||
isEditingOrder
|
isEditingOrder && chartPointAtPointer
|
||||||
? chartPointAtPointer.size
|
? chartPointAtPointer.size
|
||||||
: tooltipData!.nearestDatum?.datum.depth
|
: tooltipData!.nearestDatum?.datum.depth
|
||||||
}
|
}
|
||||||
@@ -400,8 +365,8 @@ export const DepthChart = ({
|
|||||||
[DepthChartSeries.Bids]: 'var(--color-positive)',
|
[DepthChartSeries.Bids]: 'var(--color-positive)',
|
||||||
[DepthChartSeries.MidMarket]: 'var(--color-layer-6)',
|
[DepthChartSeries.MidMarket]: 'var(--color-layer-6)',
|
||||||
}[
|
}[
|
||||||
isEditingOrder
|
isEditingOrder && chartPointAtPointer
|
||||||
? seriesKeyForOrderSide[chartPointAtPointer.side]
|
? SERIES_KEY_FOR_ORDER_SIDE[chartPointAtPointer.side]
|
||||||
: (tooltipData!.nearestDatum?.key as DepthChartSeries)
|
: (tooltipData!.nearestDatum?.key as DepthChartSeries)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -410,181 +375,22 @@ export const DepthChart = ({
|
|||||||
}
|
}
|
||||||
snapTooltipToDatumX={!isEditingOrder}
|
snapTooltipToDatumX={!isEditingOrder}
|
||||||
snapTooltipToDatumY={isEditingOrder ? false : isMobile}
|
snapTooltipToDatumY={isEditingOrder ? false : isMobile}
|
||||||
renderTooltip={({ tooltipData, colorScale }) => {
|
renderTooltip={({ tooltipData, colorScale }) =>
|
||||||
const { nearestDatum } = tooltipData || {};
|
chartPointAtPointer && (
|
||||||
|
<DepthChartTooltipContent
|
||||||
if (!isEditingOrder && !nearestDatum?.datum) return null;
|
{...{
|
||||||
|
tooltipData,
|
||||||
return (
|
colorScale,
|
||||||
<TooltipContent
|
isEditingOrder,
|
||||||
accentColor={colorScale?.(
|
chartPointAtPointer,
|
||||||
isEditingOrder
|
stringGetter,
|
||||||
? seriesKeyForOrderSide[chartPointAtPointer.side]
|
selectedLocale,
|
||||||
: nearestDatum.key
|
stepSizeDecimals,
|
||||||
)}
|
tickSizeDecimals,
|
||||||
>
|
}}
|
||||||
<h4>
|
/>
|
||||||
{isEditingOrder
|
)
|
||||||
? 'Release mouse to edit order'
|
}
|
||||||
: {
|
|
||||||
[DepthChartSeries.Bids]: 'Bids',
|
|
||||||
[DepthChartSeries.Asks]: 'Asks',
|
|
||||||
[DepthChartSeries.MidMarket]: 'Mid-Market',
|
|
||||||
}[nearestDatum.key]}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<Details
|
|
||||||
layout="column"
|
|
||||||
items={
|
|
||||||
isEditingOrder
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
key: 'side',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.SIDE }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Text}
|
|
||||||
value={
|
|
||||||
{
|
|
||||||
[OrderSide.BUY]: stringGetter({
|
|
||||||
key: STRING_KEYS.BUY,
|
|
||||||
}),
|
|
||||||
[OrderSide.SELL]: stringGetter({
|
|
||||||
key: STRING_KEYS.SELL,
|
|
||||||
}),
|
|
||||||
}[chartPointAtPointer.side]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'limitPrice',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.LIMIT_PRICE }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Fiat}
|
|
||||||
value={chartPointAtPointer.price}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'size',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.AMOUNT }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Asset}
|
|
||||||
value={chartPointAtPointer.size}
|
|
||||||
fractionDigits={stepSizeDecimals}
|
|
||||||
tag={id}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: nearestDatum?.key === DepthChartSeries.MidMarket
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
key: 'midMarketPrice',
|
|
||||||
// label: stringGetter({ key: STRING_KEYS.ORDERBOOK_MID_MARKET_PRICE }),
|
|
||||||
label: stringGetter({ key: STRING_KEYS.PRICE }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Fiat}
|
|
||||||
value={midMarketPrice}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'spread',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.ORDERBOOK_SPREAD }),
|
|
||||||
value: (
|
|
||||||
<>
|
|
||||||
<Output
|
|
||||||
type={OutputType.Fiat}
|
|
||||||
value={spread}
|
|
||||||
fractionDigits={tickSizeDecimals}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
<Output
|
|
||||||
type={OutputType.SmallPercent}
|
|
||||||
value={spreadPercent}
|
|
||||||
withParentheses
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [
|
|
||||||
{
|
|
||||||
key: 'price',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.PRICE }),
|
|
||||||
value: (
|
|
||||||
<>
|
|
||||||
{nearestDatum &&
|
|
||||||
{
|
|
||||||
[DepthChartSeries.Bids]: '≥',
|
|
||||||
[DepthChartSeries.Asks]: '≤',
|
|
||||||
}[nearestDatum.key]}
|
|
||||||
<Output
|
|
||||||
type={OutputType.Fiat}
|
|
||||||
value={nearestDatum?.datum.price}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'depth',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.TOTAL_SIZE }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Asset}
|
|
||||||
value={nearestDatum?.datum.depth}
|
|
||||||
fractionDigits={stepSizeDecimals}
|
|
||||||
tag={id}
|
|
||||||
useGrouping={false}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'cost',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.TOTAL_COST }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
useGrouping
|
|
||||||
type={OutputType.Fiat}
|
|
||||||
value={nearestDatum?.datum.price * nearestDatum?.datum.depth}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'priceImpact',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.PRICE_IMPACT }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
useGrouping
|
|
||||||
type={OutputType.Percent}
|
|
||||||
value={{
|
|
||||||
[DepthChartSeries.Asks]: () =>
|
|
||||||
MustBigNumber(nearestDatum.datum.price)
|
|
||||||
.minus(lowestAsk.price)
|
|
||||||
.div(nearestDatum.datum.price),
|
|
||||||
[DepthChartSeries.Bids]: () =>
|
|
||||||
MustBigNumber(highestBid.price)
|
|
||||||
.minus(nearestDatum.datum.price)
|
|
||||||
.div(highestBid.price),
|
|
||||||
}[nearestDatum.key]()}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</TooltipContent>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</XYChartWithPointerEvents>
|
</XYChartWithPointerEvents>
|
||||||
</EventEmitterProvider>
|
</EventEmitterProvider>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import type { RenderTooltipParams } from '@visx/xychart/lib/components/Tooltip';
|
||||||
|
import { TooltipContent } from '@/components/visx/TooltipContent';
|
||||||
|
|
||||||
|
import { FundingRateResolution, type FundingChartDatum } from '@/constants/charts';
|
||||||
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
import { FundingDirection } from '@/constants/markets';
|
||||||
|
import { useStringGetter } from '@/hooks';
|
||||||
|
|
||||||
|
import { Details, DetailsItem } from '@/components/Details';
|
||||||
|
import { Output, OutputType, ShowSign } from '@/components/Output';
|
||||||
|
|
||||||
|
type FundingChartTooltipProps = {
|
||||||
|
fundingRateView: FundingRateResolution;
|
||||||
|
latestDatum: FundingChartDatum;
|
||||||
|
} & Pick<RenderTooltipParams<FundingChartDatum>, 'tooltipData'>;
|
||||||
|
|
||||||
|
export const FundingChartTooltipContent = ({
|
||||||
|
fundingRateView,
|
||||||
|
latestDatum,
|
||||||
|
tooltipData,
|
||||||
|
}: FundingChartTooltipProps) => {
|
||||||
|
const { nearestDatum } = tooltipData || {};
|
||||||
|
const stringGetter = useStringGetter();
|
||||||
|
|
||||||
|
const tooltipDatum = nearestDatum?.datum ?? latestDatum;
|
||||||
|
const isShowingCurrentFundingRate = tooltipDatum === latestDatum;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TooltipContent
|
||||||
|
accentColor={
|
||||||
|
{
|
||||||
|
[FundingDirection.ToLong]: 'var(--color-negative)',
|
||||||
|
[FundingDirection.ToShort]: 'var(--color-positive)',
|
||||||
|
[FundingDirection.None]: 'var(--color-layer-6)',
|
||||||
|
}[tooltipDatum.direction]
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<h4>
|
||||||
|
{isShowingCurrentFundingRate
|
||||||
|
? stringGetter({ key: STRING_KEYS.CURRENT_FUNDING_RATE })
|
||||||
|
: stringGetter({ key: STRING_KEYS.HISTORICAL_FUNDING_RATE })}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<Details
|
||||||
|
layout="column"
|
||||||
|
items={
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'direction',
|
||||||
|
label: stringGetter({ key: STRING_KEYS.DIRECTION }),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.Text}
|
||||||
|
value={
|
||||||
|
{
|
||||||
|
[FundingDirection.ToLong]: `${stringGetter({
|
||||||
|
key: STRING_KEYS.SHORT_POSITION_SHORT,
|
||||||
|
})} → ${stringGetter({
|
||||||
|
key: STRING_KEYS.LONG_POSITION_SHORT,
|
||||||
|
})}`,
|
||||||
|
[FundingDirection.ToShort]: `${stringGetter({
|
||||||
|
key: STRING_KEYS.LONG_POSITION_SHORT,
|
||||||
|
})} → ${stringGetter({
|
||||||
|
key: STRING_KEYS.SHORT_POSITION_SHORT,
|
||||||
|
})}`,
|
||||||
|
[FundingDirection.None]: undefined,
|
||||||
|
}[tooltipDatum.direction]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'fundingRate',
|
||||||
|
label: stringGetter({
|
||||||
|
key: {
|
||||||
|
[FundingRateResolution.OneHour]: STRING_KEYS.RATE_1H,
|
||||||
|
[FundingRateResolution.EightHour]: STRING_KEYS.RATE_8H,
|
||||||
|
[FundingRateResolution.Annualized]: STRING_KEYS.ANNUALIZED,
|
||||||
|
}[fundingRateView],
|
||||||
|
}),
|
||||||
|
value: (
|
||||||
|
<Output
|
||||||
|
type={OutputType.SmallPercent}
|
||||||
|
value={
|
||||||
|
{
|
||||||
|
[FundingRateResolution.OneHour]: tooltipDatum.fundingRate,
|
||||||
|
[FundingRateResolution.EightHour]: tooltipDatum.fundingRate * 8,
|
||||||
|
[FundingRateResolution.Annualized]: tooltipDatum.fundingRate * (24 * 365),
|
||||||
|
}[fundingRateView]
|
||||||
|
}
|
||||||
|
showSign={ShowSign.Both}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'time',
|
||||||
|
label: isShowingCurrentFundingRate
|
||||||
|
? 'Time Remaining'
|
||||||
|
: stringGetter({ key: STRING_KEYS.TIME }),
|
||||||
|
value: <Output type={OutputType.DateTime} value={tooltipDatum.time} />,
|
||||||
|
},
|
||||||
|
].filter(Boolean) as Array<DetailsItem>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</TooltipContent>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -3,39 +3,27 @@ import { shallowEqual, useSelector } from 'react-redux';
|
|||||||
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
||||||
import { curveMonotoneX, curveStepAfter } from '@visx/curve';
|
import { curveMonotoneX, curveStepAfter } from '@visx/curve';
|
||||||
|
|
||||||
import { useBreakpoints, useStringGetter } from '@/hooks';
|
|
||||||
import { ButtonSize } from '@/constants/buttons';
|
import { ButtonSize } from '@/constants/buttons';
|
||||||
|
import { FundingRateResolution, type FundingChartDatum } from '@/constants/charts';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
import { SMALL_PERCENT_DECIMALS, TINY_PERCENT_DECIMALS } from '@/constants/numbers';
|
|
||||||
import { FundingDirection } from '@/constants/markets';
|
import { FundingDirection } from '@/constants/markets';
|
||||||
|
import { SMALL_PERCENT_DECIMALS, TINY_PERCENT_DECIMALS } from '@/constants/numbers';
|
||||||
|
import { useBreakpoints, useStringGetter } from '@/hooks';
|
||||||
|
|
||||||
import { breakpoints } from '@/styles';
|
import { breakpoints } from '@/styles';
|
||||||
|
|
||||||
import { Details, DetailsItem } from '@/components/Details';
|
import { Output, OutputType } from '@/components/Output';
|
||||||
import { Output, OutputType, ShowSign } from '@/components/Output';
|
|
||||||
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
||||||
import { ToggleGroup } from '@/components/ToggleGroup';
|
import { ToggleGroup } from '@/components/ToggleGroup';
|
||||||
|
|
||||||
import { TimeSeriesChart } from '@/components/visx/TimeSeriesChart';
|
import { TimeSeriesChart } from '@/components/visx/TimeSeriesChart';
|
||||||
import { AxisLabelOutput } from '@/components/visx/AxisLabelOutput';
|
import { AxisLabelOutput } from '@/components/visx/AxisLabelOutput';
|
||||||
import { TooltipContent } from '@/components/visx/TooltipContent';
|
|
||||||
import type { TooltipContextType } from '@visx/xychart';
|
import type { TooltipContextType } from '@visx/xychart';
|
||||||
|
|
||||||
import { calculateFundingRateHistory } from '@/state/perpetualsCalculators';
|
import { calculateFundingRateHistory } from '@/state/perpetualsCalculators';
|
||||||
|
|
||||||
import { MustBigNumber } from '@/lib/numbers';
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
|
import { FundingChartTooltipContent } from './Tooltip';
|
||||||
enum FundingRateResolution {
|
|
||||||
OneHour = 'OneHour',
|
|
||||||
EightHour = 'EightHour',
|
|
||||||
Annualized = 'Annualized',
|
|
||||||
}
|
|
||||||
|
|
||||||
type FundingChartDatum = {
|
|
||||||
time: number;
|
|
||||||
fundingRate: number;
|
|
||||||
direction: FundingDirection;
|
|
||||||
};
|
|
||||||
|
|
||||||
const FUNDING_RATE_TIME_RESOLUTION = 60 * 60 * 1000; // 1 hour
|
const FUNDING_RATE_TIME_RESOLUTION = 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
@@ -116,114 +104,20 @@ export const FundingChart = ({ selectedLocale }: ElementProps) => {
|
|||||||
{
|
{
|
||||||
[FundingDirection.ToLong]: 'var(--color-negative)',
|
[FundingDirection.ToLong]: 'var(--color-negative)',
|
||||||
[FundingDirection.ToShort]: 'var(--color-positive)',
|
[FundingDirection.ToShort]: 'var(--color-positive)',
|
||||||
|
[FundingDirection.None]: 'var(--color-layer-6)',
|
||||||
}[tooltipDatum.direction]
|
}[tooltipDatum.direction]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
renderTooltip={({ tooltipData }) => {
|
renderTooltip={({ tooltipData }) => (
|
||||||
const { nearestDatum } = tooltipData || {};
|
<FundingChartTooltipContent
|
||||||
|
fundingRateView={fundingRateView}
|
||||||
const tooltipDatum = nearestDatum?.datum ?? latestDatum;
|
tooltipData={tooltipData}
|
||||||
const isShowingCurrentFundingRate = tooltipDatum === latestDatum;
|
latestDatum={latestDatum}
|
||||||
|
/>
|
||||||
return (
|
)}
|
||||||
<TooltipContent
|
onTooltipContext={(tooltipContext) => setTooltipContext(tooltipContext)}
|
||||||
accentColor={
|
|
||||||
{
|
|
||||||
[FundingDirection.ToLong]: 'var(--color-negative)',
|
|
||||||
[FundingDirection.ToShort]: 'var(--color-positive)',
|
|
||||||
}[tooltipDatum.direction]
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<h4>
|
|
||||||
{isShowingCurrentFundingRate
|
|
||||||
? stringGetter({ key: STRING_KEYS.CURRENT_FUNDING_RATE })
|
|
||||||
: stringGetter({ key: STRING_KEYS.HISTORICAL_FUNDING_RATE })}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<Details
|
|
||||||
layout="column"
|
|
||||||
items={
|
|
||||||
[
|
|
||||||
{
|
|
||||||
key: 'direction',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.DIRECTION }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.Text}
|
|
||||||
value={
|
|
||||||
{
|
|
||||||
[FundingDirection.ToLong]: `${stringGetter({
|
|
||||||
key: STRING_KEYS.SHORT_POSITION_SHORT,
|
|
||||||
})} → ${stringGetter({
|
|
||||||
key: STRING_KEYS.LONG_POSITION_SHORT,
|
|
||||||
})}`,
|
|
||||||
[FundingDirection.ToShort]: `${stringGetter({
|
|
||||||
key: STRING_KEYS.LONG_POSITION_SHORT,
|
|
||||||
})} → ${stringGetter({
|
|
||||||
key: STRING_KEYS.SHORT_POSITION_SHORT,
|
|
||||||
})}`,
|
|
||||||
}[tooltipDatum.direction]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'fundingRate1h',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.RATE_1H }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.SmallPercent}
|
|
||||||
value={tooltipDatum.fundingRate}
|
|
||||||
showSign={ShowSign.Both}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'fundingRate8h',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.RATE_8H }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.SmallPercent}
|
|
||||||
value={tooltipDatum.fundingRate * 8}
|
|
||||||
// value={
|
|
||||||
// Math.sign(tooltipDatum.fundingRate) *
|
|
||||||
// ((Math.abs(tooltipDatum.fundingRate) + 1) ** 8 - 1)
|
|
||||||
// }
|
|
||||||
showSign={ShowSign.Both}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'fundingRateAnnualized',
|
|
||||||
label: stringGetter({ key: STRING_KEYS.ANNUALIZED }),
|
|
||||||
value: (
|
|
||||||
<Output
|
|
||||||
type={OutputType.SmallPercent}
|
|
||||||
value={tooltipDatum.fundingRate * (24 * 365)}
|
|
||||||
// value={
|
|
||||||
// Math.sign(tooltipDatum.fundingRate) *
|
|
||||||
// ((Math.abs(tooltipDatum.fundingRate) + 1) ** (24 * 365) - 1)
|
|
||||||
// }
|
|
||||||
showSign={ShowSign.Both}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'time',
|
|
||||||
label: isShowingCurrentFundingRate
|
|
||||||
? 'Time Remaining'
|
|
||||||
: stringGetter({ key: STRING_KEYS.TIME }),
|
|
||||||
value: <Output type={OutputType.DateTime} value={tooltipDatum.time} />,
|
|
||||||
},
|
|
||||||
].filter(Boolean) as Array<DetailsItem>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</TooltipContent>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
onTooltipContext={setTooltipContext}
|
|
||||||
minZoomDomain={FUNDING_RATE_TIME_RESOLUTION * 4}
|
minZoomDomain={FUNDING_RATE_TIME_RESOLUTION * 4}
|
||||||
numGridLines={1}
|
numGridLines={1}
|
||||||
slotEmpty={<LoadingSpace id="funding-chart-loading" />}
|
slotEmpty={<LoadingSpace id="funding-chart-loading" />}
|
||||||
@@ -290,6 +184,7 @@ Styled.FundingRateToggle = styled.div`
|
|||||||
Styled.CurrentFundingRate = styled.div<{ isShowing?: boolean }>`
|
Styled.CurrentFundingRate = styled.div<{ isShowing?: boolean }>`
|
||||||
place-self: start center;
|
place-self: start center;
|
||||||
padding: clamp(1.5rem, 9rem - 15%, 4rem);
|
padding: clamp(1.5rem, 9rem - 15%, 4rem);
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
font: var(--font-large-book);
|
font: var(--font-large-book);
|
||||||
|
|
||||||
@@ -108,20 +108,6 @@ export const DepositButtonAndReceipt = ({
|
|||||||
|
|
||||||
const totalFees = (summary?.bridgeFee || 0) + (summary?.gasFee || 0);
|
const totalFees = (summary?.bridgeFee || 0) + (summary?.gasFee || 0);
|
||||||
|
|
||||||
const { toAmount, toAmountMin } = useMemo(() => {
|
|
||||||
if (isCctp) {
|
|
||||||
return {
|
|
||||||
toAmount: summary?.toAmount,
|
|
||||||
toAmountMin: summary?.toAmountMin,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
toAmount: summary?.toAmount && formatUnits(BigInt(summary.toAmount), usdcDecimals),
|
|
||||||
toAmountMin: summary?.toAmountMin && formatUnits(BigInt(summary.toAmountMin), usdcDecimals),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}, [isCctp, summary]);
|
|
||||||
|
|
||||||
const submitButtonReceipt = [
|
const submitButtonReceipt = [
|
||||||
{
|
{
|
||||||
key: 'expected-deposit-amount',
|
key: 'expected-deposit-amount',
|
||||||
@@ -130,7 +116,7 @@ export const DepositButtonAndReceipt = ({
|
|||||||
{stringGetter({ key: STRING_KEYS.EXPECTED_DEPOSIT_AMOUNT })} <Tag>{usdcLabel}</Tag>
|
{stringGetter({ key: STRING_KEYS.EXPECTED_DEPOSIT_AMOUNT })} <Tag>{usdcLabel}</Tag>
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
value: <Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={toAmount} />,
|
value: <Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={summary?.toAmount} />,
|
||||||
subitems: [
|
subitems: [
|
||||||
{
|
{
|
||||||
key: 'minimum-deposit-amount',
|
key: 'minimum-deposit-amount',
|
||||||
@@ -140,7 +126,7 @@ export const DepositButtonAndReceipt = ({
|
|||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
value: (
|
value: (
|
||||||
<Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={toAmountMin} />
|
<Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={summary?.toAmountMin} />
|
||||||
),
|
),
|
||||||
tooltip: 'minimum-deposit-amount',
|
tooltip: 'minimum-deposit-amount',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user