Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606c82d940 | ||
|
|
76100c9857 | ||
|
|
9bbd8d30ed | ||
|
|
7a24e2acfd | ||
|
|
90d2ede5c6 | ||
|
|
4ca6df3d31 | ||
|
|
271c98c9bb | ||
|
|
c397c0dec9 | ||
|
|
cc53ac59d6 | ||
|
|
80be9b357f | ||
|
|
cda3e2bb6e | ||
|
|
cc6d61344b | ||
|
|
7df6e39e87 | ||
|
|
9d3413b04d | ||
|
|
628041e537 |
+3
-2
@@ -35,9 +35,10 @@
|
|||||||
"@cosmjs/encoding": "^0.31.0",
|
"@cosmjs/encoding": "^0.31.0",
|
||||||
"@cosmjs/proto-signing": "^0.31.0",
|
"@cosmjs/proto-signing": "^0.31.0",
|
||||||
"@cosmjs/stargate": "^0.31.0",
|
"@cosmjs/stargate": "^0.31.0",
|
||||||
"@dydxprotocol/abacus": "^0.2.37",
|
|
||||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||||
"@dydxprotocol/v4-client": "^0.29.0",
|
"@dydxprotocol/abacus": "^0.3.10",
|
||||||
|
"@dydxprotocol/v4-client-js": "^0.30.3",
|
||||||
|
"@dydxprotocol/v4-localization": "^0.0.16",
|
||||||
"@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-collapsible": "^1.0.3",
|
"@radix-ui/react-collapsible": "^1.0.3",
|
||||||
|
|||||||
Generated
+20
-13
@@ -1,5 +1,9 @@
|
|||||||
lockfileVersion: '6.0'
|
lockfileVersion: '6.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@0xsquid/sdk':
|
'@0xsquid/sdk':
|
||||||
specifier: ^1.7.2
|
specifier: ^1.7.2
|
||||||
@@ -23,11 +27,14 @@ dependencies:
|
|||||||
specifier: ^0.31.0
|
specifier: ^0.31.0
|
||||||
version: 0.31.0
|
version: 0.31.0
|
||||||
'@dydxprotocol/abacus':
|
'@dydxprotocol/abacus':
|
||||||
specifier: ^0.2.37
|
specifier: ^0.3.10
|
||||||
version: 0.2.37
|
version: 0.3.10
|
||||||
'@dydxprotocol/v4-client':
|
'@dydxprotocol/v4-client-js':
|
||||||
specifier: ^0.29.0
|
specifier: ^0.30.3
|
||||||
version: 0.29.0
|
version: 0.30.3
|
||||||
|
'@dydxprotocol/v4-localization':
|
||||||
|
specifier: ^0.0.16
|
||||||
|
version: 0.0.16
|
||||||
'@ethersproject/providers':
|
'@ethersproject/providers':
|
||||||
specifier: ^5.7.2
|
specifier: ^5.7.2
|
||||||
version: 5.7.2
|
version: 5.7.2
|
||||||
@@ -1139,8 +1146,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@dydxprotocol/abacus@0.2.37:
|
/@dydxprotocol/abacus@0.3.10:
|
||||||
resolution: {integrity: sha512-amoq9aVXo+lVTQGu2jsyy5/0bniOMEXpyJDmaAr2TpbrtQtw2WgyAP+se9Q5wt3yh0Mzdtsh7P2h090kH7/bZQ==}
|
resolution: {integrity: sha512-CJV6zyoQLAoDWJdgLbP1Y2QYvSPybCGpykQY+WEWk4kQKnZkjxz25LPL0b8I9LrNDt2JknOxPJfAoUDXJPfNkg==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/dydxjs@0.3.0:
|
/@dydxprotocol/dydxjs@0.3.0:
|
||||||
@@ -1160,8 +1167,8 @@ packages:
|
|||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-client@0.29.0:
|
/@dydxprotocol/v4-client-js@0.30.3:
|
||||||
resolution: {integrity: sha512-BMgm6e91LFGKB0l3lC2/0aIgayejgBa7qCwCUxr05265tggZsI3l3Cui8LNDHeb8IAQ4KPcfAJ29c96lx+rLlw==}
|
resolution: {integrity: sha512-h9nB2cU+6sWwfOTQz6sMKZZxVa/Iwp1JciUqKi5HDUyWl/4wfbczDlUqbMUUeXgBgfbb9CImxn+PjF0v7lcD5A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@cosmjs/amino': 0.30.1
|
'@cosmjs/amino': 0.30.1
|
||||||
'@cosmjs/proto-signing': 0.30.1
|
'@cosmjs/proto-signing': 0.30.1
|
||||||
@@ -1183,6 +1190,10 @@ packages:
|
|||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@dydxprotocol/v4-localization@0.0.16:
|
||||||
|
resolution: {integrity: sha512-IuTjuVdGwV6nulBLCxbNydsEkwvx7mBn8SQtPP2pQ16yfUNWMyBG3GDEXlfAk41NcPSCGXlK5Wbl0R1xaOKCRA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@emotion/is-prop-valid@1.2.1:
|
/@emotion/is-prop-valid@1.2.1:
|
||||||
resolution: {integrity: sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==}
|
resolution: {integrity: sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -15851,7 +15862,3 @@ packages:
|
|||||||
release-it: 15.11.0
|
release-it: 15.11.0
|
||||||
semver: 7.5.1
|
semver: 7.5.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
settings:
|
|
||||||
autoInstallPeers: true
|
|
||||||
excludeLinksFromLockfile: false
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Story } from '@ladle/react';
|
import type { Story } from '@ladle/react';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { OrderSideTag } from '@/components/OrderSideTag';
|
import { OrderSideTag } from '@/components/OrderSideTag';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
import { useStringGetter } from '@/hooks';
|
import { useStringGetter } from '@/hooks';
|
||||||
|
|||||||
+10
-1
@@ -1,5 +1,5 @@
|
|||||||
import Abacus, { kollections } from '@dydxprotocol/abacus';
|
import Abacus, { kollections } from '@dydxprotocol/abacus';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
import { PositionSide, TradeTypes } from './trade';
|
import { PositionSide, TradeTypes } from './trade';
|
||||||
import { STRING_KEYS } from './localization';
|
import { STRING_KEYS } from './localization';
|
||||||
|
|
||||||
@@ -36,6 +36,12 @@ export type AbacusThreadingProtocol = Omit<
|
|||||||
Abacus.exchange.dydx.abacus.protocols.ThreadingProtocol,
|
Abacus.exchange.dydx.abacus.protocols.ThreadingProtocol,
|
||||||
'__doNotUseOrImplementIt'
|
'__doNotUseOrImplementIt'
|
||||||
>;
|
>;
|
||||||
|
export type AbacusFileSystemProtocol = Omit<
|
||||||
|
Abacus.exchange.dydx.abacus.protocols.FileSystemProtocol,
|
||||||
|
'__doNotUseOrImplementIt'
|
||||||
|
>;
|
||||||
|
|
||||||
|
export type FileLocation = Abacus.exchange.dydx.abacus.protocols.FileLocation;
|
||||||
export type ThreadingType = Abacus.exchange.dydx.abacus.protocols.ThreadingType;
|
export type ThreadingType = Abacus.exchange.dydx.abacus.protocols.ThreadingType;
|
||||||
export const CoroutineTimer = Abacus.exchange.dydx.abacus.utils.CoroutineTimer;
|
export const CoroutineTimer = Abacus.exchange.dydx.abacus.utils.CoroutineTimer;
|
||||||
|
|
||||||
@@ -180,6 +186,9 @@ export const RiskLevel = Abacus.exchange.dydx.abacus.utils.RiskLevel;
|
|||||||
const riskLevels = [...RiskLevel.values()] as const;
|
const riskLevels = [...RiskLevel.values()] as const;
|
||||||
export type RiskLevels = (typeof riskLevels)[number];
|
export type RiskLevels = (typeof riskLevels)[number];
|
||||||
|
|
||||||
|
// ------ Notifications ------ //
|
||||||
|
export type AbacusNotification = Abacus.exchange.dydx.abacus.output.Notification;
|
||||||
|
|
||||||
// ------ Enum Conversions ------ //
|
// ------ Enum Conversions ------ //
|
||||||
type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
||||||
? A
|
? A
|
||||||
|
|||||||
+18
-62
@@ -1,73 +1,29 @@
|
|||||||
|
import { ENDPOINTS, DEV_ENDPOINTS } from '@dydxprotocol/v4-localization';
|
||||||
|
|
||||||
|
export const NETWORK_ENDPOINTS = import.meta.env.MODE === 'production' ? ENDPOINTS : DEV_ENDPOINTS;
|
||||||
|
|
||||||
|
export const CLIENT_NETWORK_CONFIGS: Record<
|
||||||
|
string,
|
||||||
|
(typeof NETWORK_ENDPOINTS.environments)[number]
|
||||||
|
> = Object.fromEntries(
|
||||||
|
NETWORK_ENDPOINTS.environments.map((environment) => [environment.environment, environment])
|
||||||
|
);
|
||||||
|
|
||||||
|
export const DEFAULT_APP_ENVIRONMENT = NETWORK_ENDPOINTS.defaultEnvironment;
|
||||||
|
|
||||||
export enum DydxV4Network {
|
export enum DydxV4Network {
|
||||||
V4Mainnet = 'dydxprotocol-mainnet',
|
V4Mainnet = 'dydxprotocol-mainnet',
|
||||||
V4Staging = 'dydxprotocol-staging',
|
V4Staging = 'dydxprotocol-staging',
|
||||||
V4Testnet2 = 'dydxprotocol-testnet-2',
|
V4Testnet2 = 'dydxprotocol-testnet',
|
||||||
V4Local = 'dydxprotocol-dev',
|
V4Local = 'dydxprotocol-dev',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DydxV3Network {
|
export type DydxNetwork = keyof typeof CLIENT_NETWORK_CONFIGS;
|
||||||
V3Mainnet = '1',
|
|
||||||
V3Testnet = '5',
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isDydxV4Network(network: any): network is DydxV4Network {
|
export function isDydxV4Network(network: any): boolean {
|
||||||
return Object.values(DydxV4Network).includes(network);
|
return CLIENT_NETWORK_CONFIGS[network]?.version === 'v4';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidDydxNetwork(network: any): boolean {
|
export function isValidDydxNetwork(network: any): boolean {
|
||||||
return isDydxV4Network(network) || Object.values(DydxV3Network).includes(network);
|
return Object.keys(CLIENT_NETWORK_CONFIGS).includes(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DydxNetwork = DydxV4Network | DydxV3Network;
|
|
||||||
|
|
||||||
export const CHAIN_IDS = {
|
|
||||||
[DydxV4Network.V4Mainnet]: '',
|
|
||||||
[DydxV4Network.V4Staging]: 'dydxprotocol-testnet',
|
|
||||||
[DydxV4Network.V4Testnet2]: 'dydx-testnet-2',
|
|
||||||
[DydxV4Network.V4Local]: 'dydxprotocol-testnet',
|
|
||||||
[DydxV3Network.V3Mainnet]: '1',
|
|
||||||
[DydxV3Network.V3Testnet]: '5',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DEFAULT_APP_ENVIRONMENT =
|
|
||||||
import.meta.env.MODE === 'production' ? DydxV4Network.V4Testnet2 : DydxV4Network.V4Staging;
|
|
||||||
|
|
||||||
export const CLIENT_NETWORK_CONFIGS: Record<
|
|
||||||
DydxV4Network,
|
|
||||||
{
|
|
||||||
chainId: string;
|
|
||||||
validatorUrl: string;
|
|
||||||
faucetUrl: string;
|
|
||||||
indexerUrl: string;
|
|
||||||
ethereumChainId: number;
|
|
||||||
}
|
|
||||||
> = {
|
|
||||||
[DydxV4Network.V4Mainnet]: {
|
|
||||||
chainId: CHAIN_IDS[DydxV4Network.V4Mainnet],
|
|
||||||
validatorUrl: import.meta.env.VITE_VALIDATOR_URL_STAGE,
|
|
||||||
faucetUrl: import.meta.env.VITE_FAUCET_URL_STAGE,
|
|
||||||
indexerUrl: import.meta.env.VITE_INDEXER_URL_STAGE,
|
|
||||||
ethereumChainId: 1,
|
|
||||||
},
|
|
||||||
[DydxV4Network.V4Local]: {
|
|
||||||
chainId: CHAIN_IDS[DydxV4Network.V4Local],
|
|
||||||
validatorUrl: import.meta.env.VITE_VALIDATOR_URL_DEV,
|
|
||||||
faucetUrl: import.meta.env.VITE_FAUCET_URL_DEV,
|
|
||||||
indexerUrl: import.meta.env.VITE_INDEXER_URL_DEV,
|
|
||||||
ethereumChainId: 5,
|
|
||||||
},
|
|
||||||
[DydxV4Network.V4Staging]: {
|
|
||||||
chainId: CHAIN_IDS[DydxV4Network.V4Staging],
|
|
||||||
validatorUrl: import.meta.env.VITE_VALIDATOR_URL_STAGE,
|
|
||||||
faucetUrl: import.meta.env.VITE_FAUCET_URL_STAGE,
|
|
||||||
indexerUrl: import.meta.env.VITE_INDEXER_URL_STAGE,
|
|
||||||
ethereumChainId: 5,
|
|
||||||
},
|
|
||||||
[DydxV4Network.V4Testnet2]: {
|
|
||||||
chainId: CHAIN_IDS[DydxV4Network.V4Testnet2],
|
|
||||||
validatorUrl: import.meta.env.VITE_VALIDATOR_URL_TESTNET2,
|
|
||||||
faucetUrl: import.meta.env.VITE_FAUCET_URL_TESTNET2,
|
|
||||||
indexerUrl: import.meta.env.VITE_INDEXER_URL_TESTNET2,
|
|
||||||
ethereumChainId: 5,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { AlertType } from '@/constants/alerts';
|
import { AlertType } from '@/constants/alerts';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ export type WalletConnection = {
|
|||||||
|
|
||||||
// dYdX Chain wallets
|
// dYdX Chain wallets
|
||||||
|
|
||||||
import { USDC_DENOM, type Onboarding, DYDX_DENOM } from '@dydxprotocol/v4-client';
|
import { USDC_DENOM, type Onboarding, DYDX_DENOM } from '@dydxprotocol/v4-client-js';
|
||||||
import type { suggestChain } from 'graz';
|
import type { suggestChain } from 'graz';
|
||||||
|
|
||||||
export const COSMOS_DERIVATION_PATH = "m/44'/118'/0'/0/0";
|
export const COSMOS_DERIVATION_PATH = "m/44'/118'/0'/0/0";
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import { useLocation } from 'react-router-dom';
|
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
|
|
||||||
import { LanguageCode, ResolutionString, widget } from 'public/tradingview/charting_library';
|
import { LanguageCode, ResolutionString, widget } from 'public/tradingview/charting_library';
|
||||||
@@ -14,9 +13,8 @@ import { store } from '@/state/_store';
|
|||||||
import { getSelectedNetwork } from '@/state/appSelectors';
|
import { getSelectedNetwork } from '@/state/appSelectors';
|
||||||
import { getAppTheme } from '@/state/configsSelectors';
|
import { getAppTheme } from '@/state/configsSelectors';
|
||||||
import { getSelectedLocale } from '@/state/localizationSelectors';
|
import { getSelectedLocale } from '@/state/localizationSelectors';
|
||||||
import { getMarketIds } from '@/state/perpetualsSelectors';
|
import { getCurrentMarketId, getMarketIds } from '@/state/perpetualsSelectors';
|
||||||
|
|
||||||
import { getMarketIdFromLocation } from '@/lib/tradeData';
|
|
||||||
import { getDydxDatafeed } from '@/lib/tradingView/dydxfeed';
|
import { getDydxDatafeed } from '@/lib/tradingView/dydxfeed';
|
||||||
import { getSavedResolution, getWidgetOptions, getWidgetOverrides } from '@/lib/tradingView/utils';
|
import { getSavedResolution, getWidgetOptions, getWidgetOverrides } from '@/lib/tradingView/utils';
|
||||||
|
|
||||||
@@ -30,8 +28,7 @@ export const useTradingView = ({
|
|||||||
tvWidgetRef: React.MutableRefObject<any>;
|
tvWidgetRef: React.MutableRefObject<any>;
|
||||||
setIsChartReady: React.Dispatch<React.SetStateAction<boolean>>;
|
setIsChartReady: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
}) => {
|
}) => {
|
||||||
const location = useLocation();
|
const marketId = useSelector(getCurrentMarketId);
|
||||||
const marketId = getMarketIdFromLocation(location);
|
|
||||||
const appTheme = useSelector(getAppTheme);
|
const appTheme = useSelector(getAppTheme);
|
||||||
const marketIds = useSelector(getMarketIds, shallowEqual);
|
const marketIds = useSelector(getMarketIds, shallowEqual);
|
||||||
const selectedLocale = useSelector(getSelectedLocale);
|
const selectedLocale = useSelector(getSelectedLocale);
|
||||||
@@ -50,7 +47,6 @@ export const useTradingView = ({
|
|||||||
if (hasMarkets) {
|
if (hasMarkets) {
|
||||||
const widgetOptions = getWidgetOptions();
|
const widgetOptions = getWidgetOptions();
|
||||||
const widgetOverrides = getWidgetOverrides(appTheme);
|
const widgetOverrides = getWidgetOverrides(appTheme);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
// debug: true,
|
// debug: true,
|
||||||
...widgetOptions,
|
...widgetOptions,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { StargateClient } from '@cosmjs/stargate';
|
|||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
import { formatUnits } from 'viem';
|
import { formatUnits } from 'viem';
|
||||||
|
|
||||||
import { CLIENT_NETWORK_CONFIGS, type DydxV4Network } from '@/constants/networks';
|
import { CLIENT_NETWORK_CONFIGS } from '@/constants/networks';
|
||||||
import { QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
import { QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
||||||
import { EthereumAddress } from '@/constants/wallets';
|
import { EthereumAddress } from '@/constants/wallets';
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ import { MustBigNumber } from '@/lib/numbers';
|
|||||||
import { getSelectedNetwork } from '@/state/appSelectors';
|
import { getSelectedNetwork } from '@/state/appSelectors';
|
||||||
|
|
||||||
import { useAccounts } from './useAccounts';
|
import { useAccounts } from './useAccounts';
|
||||||
// import { useDydxClient } from './useDydxClient';
|
|
||||||
import { usePollNativeTokenBalance } from './usePollNativeTokenBalance';
|
import { usePollNativeTokenBalance } from './usePollNativeTokenBalance';
|
||||||
|
|
||||||
type UseAccountBalanceProps = {
|
type UseAccountBalanceProps = {
|
||||||
@@ -49,10 +48,8 @@ export const useAccountBalance = ({
|
|||||||
}: UseAccountBalanceProps = {}) => {
|
}: UseAccountBalanceProps = {}) => {
|
||||||
const { evmAddress, dydxAddress } = useAccounts();
|
const { evmAddress, dydxAddress } = useAccounts();
|
||||||
|
|
||||||
// TODO: let Abacus / useDydxClient handle EVM chain IDs
|
|
||||||
// const { networkConfig } = useDydxClient();
|
|
||||||
const selectedNetwork = useSelector(getSelectedNetwork);
|
const selectedNetwork = useSelector(getSelectedNetwork);
|
||||||
const evmChainId = Number(CLIENT_NETWORK_CONFIGS[selectedNetwork as DydxV4Network].ethereumChainId);
|
const evmChainId = Number(CLIENT_NETWORK_CONFIGS[selectedNetwork].ethereumChainId);
|
||||||
|
|
||||||
const evmQuery = useBalance({
|
const evmQuery = useBalance({
|
||||||
enabled: Boolean(!isCosmosChain && addressOrDenom?.startsWith('0x')),
|
enabled: Boolean(!isCosmosChain && addressOrDenom?.startsWith('0x')),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useContext, createContext, useEffect, useState, useMemo }
|
|||||||
|
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { AES, enc } from 'crypto-js';
|
import { AES, enc } from 'crypto-js';
|
||||||
import { LocalWallet, USDC_DENOM, type Subaccount } from '@dydxprotocol/v4-client';
|
import { LocalWallet, USDC_DENOM, type Subaccount } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { OnboardingGuard, OnboardingState, type EvmDerivedAddresses } from '@/constants/account';
|
import { OnboardingGuard, OnboardingState, type EvmDerivedAddresses } from '@/constants/account';
|
||||||
import { LocalStorageKey, LOCAL_STORAGE_VERSIONS } from '@/constants/localStorage';
|
import { LocalStorageKey, LOCAL_STORAGE_VERSIONS } from '@/constants/localStorage';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const useCurrentMarketId = () => {
|
|||||||
|
|
||||||
const validId = useMemo(() => {
|
const validId = useMemo(() => {
|
||||||
if (marketIds.length === 0) return marketId ?? lastViewedMarket;
|
if (marketIds.length === 0) return marketId ?? lastViewedMarket;
|
||||||
if (!marketIds.includes(marketId)) return DEFAULT_MARKETID;
|
if (!marketIds.includes(marketId ?? lastViewedMarket)) return DEFAULT_MARKETID;
|
||||||
return marketId ?? lastViewedMarket;
|
return marketId ?? lastViewedMarket;
|
||||||
}, [marketIds, marketId]);
|
}, [marketIds, marketId]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DydxV4Network } from '@/constants/networks';
|
import { isDydxV4Network } from '@/constants/networks';
|
||||||
import { WalletType } from '@/constants/wallets';
|
import { WalletType } from '@/constants/wallets';
|
||||||
|
|
||||||
import { isTruthy } from '@/lib/isTruthy';
|
import { isTruthy } from '@/lib/isTruthy';
|
||||||
@@ -11,9 +11,7 @@ export const useDisplayedWallets = () => {
|
|||||||
return [
|
return [
|
||||||
WalletType.MetaMask,
|
WalletType.MetaMask,
|
||||||
|
|
||||||
import.meta.env.MODE !== 'production' &&
|
import.meta.env.MODE !== 'production' && isDydxV4Network(selectedNetwork) && WalletType.Keplr,
|
||||||
[DydxV4Network.V4Testnet2, DydxV4Network.V4Staging].includes(selectedNetwork) &&
|
|
||||||
WalletType.Keplr,
|
|
||||||
|
|
||||||
WalletType.WalletConnect2,
|
WalletType.WalletConnect2,
|
||||||
WalletType.WalletConnect,
|
WalletType.WalletConnect,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
onboarding,
|
onboarding,
|
||||||
Network,
|
Network,
|
||||||
ValidatorConfig,
|
ValidatorConfig,
|
||||||
} from '@dydxprotocol/v4-client';
|
} from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import type { ResolutionString } from 'public/tradingview/charting_library';
|
import type { ResolutionString } from 'public/tradingview/charting_library';
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { useDispatch } from 'react-redux';
|
|||||||
|
|
||||||
import { LocalStorageKey } from '@/constants/localStorage';
|
import { LocalStorageKey } from '@/constants/localStorage';
|
||||||
|
|
||||||
import {
|
import { DEFAULT_APP_ENVIRONMENT, DydxNetwork, isValidDydxNetwork } from '@/constants/networks';
|
||||||
DEFAULT_APP_ENVIRONMENT,
|
|
||||||
DydxNetwork,
|
|
||||||
isValidDydxNetwork,
|
|
||||||
} from '@/constants/networks';
|
|
||||||
|
|
||||||
import { useLocalStorage } from '@/hooks';
|
import { useLocalStorage } from '@/hooks';
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useQuery } from 'react-query';
|
|||||||
import { useAccounts } from '@/hooks';
|
import { useAccounts } from '@/hooks';
|
||||||
|
|
||||||
import { DydxAddress } from '@/constants/wallets';
|
import { DydxAddress } from '@/constants/wallets';
|
||||||
import { DYDX_DENOM } from '@dydxprotocol/v4-client';
|
import { DYDX_DENOM } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
const ACCOUNT_BALANCE_POLLING_INTERVAL = 60_000;
|
const ACCOUNT_BALANCE_POLLING_INTERVAL = 60_000;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { LocalStorageKey } from '@/constants/localStorage';
|
import { LocalStorageKey } from '@/constants/localStorage';
|
||||||
import { DEFAULT_APP_ENVIRONMENT, DydxNetwork, DydxV4Network } from '@/constants/networks';
|
import { DEFAULT_APP_ENVIRONMENT, DydxNetwork } from '@/constants/networks';
|
||||||
|
|
||||||
import { useAccounts, useLocalStorage } from '@/hooks';
|
import { useAccounts, useLocalStorage } from '@/hooks';
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
DYDX_DENOM,
|
DYDX_DENOM,
|
||||||
USDC_DENOM,
|
USDC_DENOM,
|
||||||
GAS_PRICE_DYDX_DENOM,
|
GAS_PRICE_DYDX_DENOM,
|
||||||
} from '@dydxprotocol/v4-client';
|
} from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
HumanReadableCancelOrderPayload,
|
HumanReadableCancelOrderPayload,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AbacusOrderSide,
|
AbacusOrderSide,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Network,
|
Network,
|
||||||
NetworkOptimizer,
|
NetworkOptimizer,
|
||||||
ValidatorConfig,
|
ValidatorConfig,
|
||||||
} from '@dydxprotocol/v4-client';
|
} from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type AbacusDydxChainQueriesProtocol,
|
type AbacusDydxChainQueriesProtocol,
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import type { AbacusFileSystemProtocol, FileLocation, Nullable } from '@/constants/abacus';
|
||||||
|
import { NETWORK_ENDPOINTS } from '@/constants/networks';
|
||||||
|
|
||||||
|
export const ENDPOINTS_PATH =
|
||||||
|
import.meta.env.MODE === 'production'
|
||||||
|
? 'config/prod/endpoints.json'
|
||||||
|
: 'config/staging/dev_endpoints.json';
|
||||||
|
|
||||||
|
class AbacusFileSystem implements AbacusFileSystemProtocol {
|
||||||
|
readTextFile(location: FileLocation, path: string): Nullable<string> {
|
||||||
|
if (path === ENDPOINTS_PATH) {
|
||||||
|
return JSON.stringify(NETWORK_ENDPOINTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeTextFile(path: string, text: string): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AbacusFileSystem;
|
||||||
@@ -36,8 +36,8 @@ import AbacusStateNotifier from './stateNotification';
|
|||||||
import AbacusLocalizer from './localizer';
|
import AbacusLocalizer from './localizer';
|
||||||
import AbacusFormatter from './formatter';
|
import AbacusFormatter from './formatter';
|
||||||
import AbacusThreading from './threading';
|
import AbacusThreading from './threading';
|
||||||
|
import AbacusFileSystem, { ENDPOINTS_PATH } from './filesystem';
|
||||||
import { LocaleSeparators } from '../numbers';
|
import { LocaleSeparators } from '../numbers';
|
||||||
|
|
||||||
class AbacusStateManager {
|
class AbacusStateManager {
|
||||||
private store: RootStore | undefined;
|
private store: RootStore | undefined;
|
||||||
private currentMarket: string | undefined;
|
private currentMarket: string | undefined;
|
||||||
@@ -62,7 +62,7 @@ class AbacusStateManager {
|
|||||||
null,
|
null,
|
||||||
new AbacusThreading(),
|
new AbacusThreading(),
|
||||||
new CoroutineTimer(),
|
new CoroutineTimer(),
|
||||||
null
|
new AbacusFileSystem()
|
||||||
);
|
);
|
||||||
|
|
||||||
const uiImplementations = new UIImplementations(
|
const uiImplementations = new UIImplementations(
|
||||||
@@ -72,6 +72,8 @@ class AbacusStateManager {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.stateManager = new AsyncAbacusStateManager(
|
this.stateManager = new AsyncAbacusStateManager(
|
||||||
|
import.meta.env.SHARED_RESOURCES_URI,
|
||||||
|
ENDPOINTS_PATH,
|
||||||
ioImplementations,
|
ioImplementations,
|
||||||
uiImplementations,
|
uiImplementations,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import { kollections } from '@dydxprotocol/abacus';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AbacusApiState,
|
AbacusApiState,
|
||||||
|
AbacusNotification,
|
||||||
AbacusStateNotificationProtocol,
|
AbacusStateNotificationProtocol,
|
||||||
Asset,
|
Asset,
|
||||||
Nullable,
|
Nullable,
|
||||||
@@ -36,6 +39,14 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
|
|||||||
this.store = undefined;
|
this.store = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environmentsChanged(): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationsChanged(notifications: kollections.List<AbacusNotification>): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
stateChanged(
|
stateChanged(
|
||||||
updatedState: Nullable<PerpetualState>,
|
updatedState: Nullable<PerpetualState>,
|
||||||
incomingChanges: Nullable<PerpetualStateChanges>
|
incomingChanges: Nullable<PerpetualStateChanges>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { type Location, matchPath } from 'react-router-dom';
|
import { type Location, matchPath } from 'react-router-dom';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { StringGetterFunction } from '@/constants/localization';
|
import { StringGetterFunction } from '@/constants/localization';
|
||||||
|
|
||||||
|
|||||||
@@ -1209,5 +1209,20 @@
|
|||||||
"NODE_DOWN": "Node cannot be reached.",
|
"NODE_DOWN": "Node cannot be reached.",
|
||||||
"NODE_HALTED": "Node has halted on block {BLOCK_NUMBER}.",
|
"NODE_HALTED": "Node has halted on block {BLOCK_NUMBER}.",
|
||||||
"UNKNOWN_API_ERROR": "Unknown API error"
|
"UNKNOWN_API_ERROR": "Unknown API error"
|
||||||
|
},
|
||||||
|
"CHAIN": {
|
||||||
|
"V3_MAINNET": "V3 Mainnet",
|
||||||
|
"V3_GOERLI": "V3 Staging",
|
||||||
|
"V4_DEVNET": "V4 Dev 1",
|
||||||
|
"V4_DEVNET_2": "V4 Dev 2",
|
||||||
|
"V4_DEVNET_3": "V4 Dev 3",
|
||||||
|
"V4_DEVNET_4": "V4 Dev 4",
|
||||||
|
"V4_DEVNET_5": "V4 Dev 5",
|
||||||
|
"V4_STAGING": "V4 Staging",
|
||||||
|
"V4_TESTNET2": "V4 Testnet",
|
||||||
|
"V4_TESTNET2_DSRV": "V4 Testnet (DSRV)",
|
||||||
|
"V4_TESTNET2_DYDX": "V4 Testnet (dYdX)",
|
||||||
|
"V4_TESTNET2_NODEFLEET": "V4 Testnet (nodefleet)",
|
||||||
|
"V4_TESTNET2_IMPERATOR": "V4 Testnet (Imperator)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
import { SubaccountPosition } from '@/constants/abacus';
|
import { SubaccountPosition } from '@/constants/abacus';
|
||||||
import { OnboardingGuard, OnboardingState, OnboardingSteps } from '@/constants/account';
|
import { OnboardingState, OnboardingSteps } from '@/constants/account';
|
||||||
import { isDydxV4Network } from '@/constants/networks';
|
import { isDydxV4Network } from '@/constants/networks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import { Details } from '@/components/Details';
|
|||||||
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
import { LoadingSpace } from '@/components/Loading/LoadingSpinner';
|
||||||
import { Output, OutputType } from '@/components/Output';
|
import { Output, OutputType } from '@/components/Output';
|
||||||
|
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const theme = buildChartTheme({
|
const theme = buildChartTheme({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import styled, { AnyStyledComponent } from 'styled-components';
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { AbacusApiStatus } from '@/constants/abacus';
|
import { AbacusApiStatus } from '@/constants/abacus';
|
||||||
import { DydxV4Network } from '@/constants/networks';
|
import { CLIENT_NETWORK_CONFIGS } from '@/constants/networks';
|
||||||
import { UNICODE } from '@/constants/unicode';
|
import { UNICODE } from '@/constants/unicode';
|
||||||
|
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
@@ -44,7 +44,7 @@ export const ExchangeOfflineDialog = ({ preventClose, setIsOpen }: ElementProps)
|
|||||||
>
|
>
|
||||||
<Styled.Content>
|
<Styled.Content>
|
||||||
<p>{statusErrorMessage}</p>
|
<p>{statusErrorMessage}</p>
|
||||||
{selectedNetwork === DydxV4Network.V4Testnet2 && (
|
{CLIENT_NETWORK_CONFIGS[selectedNetwork].dydxChainId === 'dydx-testnet-2' && (
|
||||||
<Styled.Link href="https://status.v4testnet.dydx.exchange">
|
<Styled.Link href="https://status.v4testnet.dydx.exchange">
|
||||||
{stringGetter({ key: STRING_KEYS.LEARN_MORE })} {UNICODE.ARROW_RIGHT}
|
{stringGetter({ key: STRING_KEYS.LEARN_MORE })} {UNICODE.ARROW_RIGHT}
|
||||||
</Styled.Link>
|
</Styled.Link>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useSignTypedData } from 'wagmi';
|
import { useSignTypedData } from 'wagmi';
|
||||||
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { AES } from 'crypto-js';
|
import { AES } from 'crypto-js';
|
||||||
|
|
||||||
import { EvmDerivedAccountStatus } from '@/constants/account';
|
import { EvmDerivedAccountStatus } from '@/constants/account';
|
||||||
@@ -9,7 +9,7 @@ import { AlertType } from '@/constants/alerts';
|
|||||||
import { AnalyticsEvent } from '@/constants/analytics';
|
import { AnalyticsEvent } from '@/constants/analytics';
|
||||||
import { ButtonAction } from '@/constants/buttons';
|
import { ButtonAction } from '@/constants/buttons';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
import { CLIENT_NETWORK_CONFIGS, DydxV4Network } from '@/constants/networks';
|
import { CLIENT_NETWORK_CONFIGS } from '@/constants/networks';
|
||||||
import { DydxAddress, SIGN_TYPED_DATA } from '@/constants/wallets';
|
import { DydxAddress, SIGN_TYPED_DATA } from '@/constants/wallets';
|
||||||
|
|
||||||
import { useAccounts, useBreakpoints, useDydxClient, useStringGetter } from '@/hooks';
|
import { useAccounts, useBreakpoints, useDydxClient, useStringGetter } from '@/hooks';
|
||||||
@@ -54,7 +54,7 @@ export const GenerateKeys = ({
|
|||||||
// 1. Switch network
|
// 1. Switch network
|
||||||
const selectedNetwork = useSelector(getSelectedNetwork);
|
const selectedNetwork = useSelector(getSelectedNetwork);
|
||||||
|
|
||||||
const chainId = Number(CLIENT_NETWORK_CONFIGS[selectedNetwork as DydxV4Network].ethereumChainId);
|
const chainId = Number(CLIENT_NETWORK_CONFIGS[selectedNetwork].ethereumChainId);
|
||||||
|
|
||||||
const { isMatchingNetwork, matchNetwork, isSwitchingNetwork } = useMatchingEvmNetwork({
|
const { isMatchingNetwork, matchNetwork, isSwitchingNetwork } = useMatchingEvmNetwork({
|
||||||
chainId,
|
chainId,
|
||||||
|
|||||||
@@ -2,14 +2,10 @@ import { type FormEvent, useCallback, useEffect, useMemo, useState } from 'react
|
|||||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||||
import { type NumberFormatValues } from 'react-number-format';
|
import { type NumberFormatValues } from 'react-number-format';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client';
|
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client-js';
|
||||||
import { ethers } from 'ethers';
|
import { ethers } from 'ethers';
|
||||||
|
|
||||||
import {
|
import { TransferInputField, TransferInputTokenResource, TransferType } from '@/constants/abacus';
|
||||||
TransferInputField,
|
|
||||||
TransferInputTokenResource,
|
|
||||||
TransferType,
|
|
||||||
} from '@/constants/abacus';
|
|
||||||
import { AlertType } from '@/constants/alerts';
|
import { AlertType } from '@/constants/alerts';
|
||||||
import { ButtonSize } from '@/constants/buttons';
|
import { ButtonSize } from '@/constants/buttons';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
@@ -54,8 +50,13 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
|
|
||||||
const { signerWagmi } = useAccounts();
|
const { signerWagmi } = useAccounts();
|
||||||
|
|
||||||
const { requestPayload, token, chain: chainIdStr, resources } = useSelector(getTransferInputs, shallowEqual) || {};
|
const {
|
||||||
const chainId = chainIdStr ? parseInt(chainIdStr) : undefined
|
requestPayload,
|
||||||
|
token,
|
||||||
|
chain: chainIdStr,
|
||||||
|
resources,
|
||||||
|
} = useSelector(getTransferInputs, shallowEqual) || {};
|
||||||
|
const chainId = chainIdStr ? parseInt(chainIdStr) : undefined;
|
||||||
|
|
||||||
// User inputs
|
// User inputs
|
||||||
const sourceToken = useMemo(
|
const sourceToken = useMemo(
|
||||||
@@ -197,7 +198,6 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
abacusStateManager.clearTransferInputValues();
|
abacusStateManager.clearTransferInputValues();
|
||||||
setFromAmount('');
|
setFromAmount('');
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
setError(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import type { ChangeEvent, FormEvent } from 'react';
|
|||||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||||
import type { NumberFormatValues } from 'react-number-format';
|
import type { NumberFormatValues } from 'react-number-format';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client';
|
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { TransferInputField, TransferInputTokenResource, TransferType } from '@/constants/abacus';
|
import { TransferInputField, TransferInputTokenResource, TransferType } from '@/constants/abacus';
|
||||||
import { AlertType } from '@/constants/alerts';
|
import { AlertType } from '@/constants/alerts';
|
||||||
import { ButtonSize } from '@/constants/buttons';
|
import { ButtonSize } from '@/constants/buttons';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
import { NumberSign, QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
import { NumberSign, QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import type { Story } from '@ladle/react';
|
import type { Story } from '@ladle/react';
|
||||||
import styled, { AnyStyledComponent } from 'styled-components';
|
import styled, { AnyStyledComponent } from 'styled-components';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { PositionSide } from '@/constants/trade';
|
import { PositionSide } from '@/constants/trade';
|
||||||
import { breakpoints } from '@/styles';
|
import { breakpoints } from '@/styles';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { type Dispatch, type SetStateAction, useCallback, useMemo } from 'react'
|
|||||||
import styled, { AnyStyledComponent, css } from 'styled-components';
|
import styled, { AnyStyledComponent, css } from 'styled-components';
|
||||||
import { Root, Thumb, Track } from '@radix-ui/react-slider';
|
import { Root, Thumb, Track } from '@radix-ui/react-slider';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { type Nullable, TradeInputField } from '@/constants/abacus';
|
import { type Nullable, TradeInputField } from '@/constants/abacus';
|
||||||
import { PositionSide } from '@/constants/trade';
|
import { PositionSide } from '@/constants/trade';
|
||||||
@@ -43,9 +43,7 @@ export const LeverageSlider = ({
|
|||||||
},
|
},
|
||||||
[PositionSide.Long]: {
|
[PositionSide.Long]: {
|
||||||
min:
|
min:
|
||||||
orderSide === OrderSide.BUY
|
orderSide === OrderSide.BUY ? leverageBN.toNumber() : maxLeverageBN.negated().toNumber(),
|
||||||
? leverageBN.toNumber()
|
|
||||||
: maxLeverageBN.negated().toNumber(),
|
|
||||||
max: orderSide === OrderSide.BUY ? maxLeverageBN.toNumber() : leverageBN.toNumber(),
|
max: orderSide === OrderSide.BUY ? maxLeverageBN.toNumber() : leverageBN.toNumber(),
|
||||||
midpoint:
|
midpoint:
|
||||||
orderSide === OrderSide.SELL
|
orderSide === OrderSide.SELL
|
||||||
@@ -56,9 +54,7 @@ export const LeverageSlider = ({
|
|||||||
},
|
},
|
||||||
[PositionSide.Short]: {
|
[PositionSide.Short]: {
|
||||||
min:
|
min:
|
||||||
orderSide === OrderSide.BUY
|
orderSide === OrderSide.BUY ? leverageBN.toNumber() : maxLeverageBN.negated().toNumber(),
|
||||||
? leverageBN.toNumber()
|
|
||||||
: maxLeverageBN.negated().toNumber(),
|
|
||||||
max: orderSide === OrderSide.BUY ? maxLeverageBN.toNumber() : leverageBN.toNumber(),
|
max: orderSide === OrderSide.BUY ? maxLeverageBN.toNumber() : leverageBN.toNumber(),
|
||||||
midpoint:
|
midpoint:
|
||||||
orderSide === OrderSide.BUY
|
orderSide === OrderSide.BUY
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Dispatch, SetStateAction } from 'react';
|
import type { Dispatch, SetStateAction } from 'react';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import styled, { AnyStyledComponent } from 'styled-components';
|
import styled, { AnyStyledComponent } from 'styled-components';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { TradeInputField, Nullable } from '@/constants/abacus';
|
import { TradeInputField, Nullable } from '@/constants/abacus';
|
||||||
import { ButtonShape } from '@/constants/buttons';
|
import { ButtonShape } from '@/constants/buttons';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import type { TradeInputSummary } from '@/constants/abacus';
|
import type { TradeInputSummary } from '@/constants/abacus';
|
||||||
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
|
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { AbacusOrderSide } from '@/constants/abacus';
|
import { AbacusOrderSide } from '@/constants/abacus';
|
||||||
import { ButtonShape, ButtonSize } from '@/constants/buttons';
|
import { ButtonShape, ButtonSize } from '@/constants/buttons';
|
||||||
@@ -31,9 +31,7 @@ export const TradeSideToggle = memo(() => {
|
|||||||
onValueChange={(side: OrderSide) => {
|
onValueChange={(side: OrderSide) => {
|
||||||
abacusStateManager.setTradeValue({
|
abacusStateManager.setTradeValue({
|
||||||
value:
|
value:
|
||||||
side === OrderSide.BUY
|
side === OrderSide.BUY ? AbacusOrderSide.buy.rawValue : AbacusOrderSide.sell.rawValue,
|
||||||
? AbacusOrderSide.buy.rawValue
|
|
||||||
: AbacusOrderSide.sell.rawValue,
|
|
||||||
field: TradeInputField.side,
|
field: TradeInputField.side,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import { shallowEqual, useSelector } from 'react-redux';
|
|||||||
import type { SyntheticInputEvent } from 'react-number-format/types/types';
|
import type { SyntheticInputEvent } from 'react-number-format/types/types';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { StdFee } from '@cosmjs/stargate';
|
import { StdFee } from '@cosmjs/stargate';
|
||||||
import { validation } from '@dydxprotocol/v4-client';
|
import { validation } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { TransferInputField, TransferType } from '@/constants/abacus';
|
import { TransferInputField, TransferType } from '@/constants/abacus';
|
||||||
import { AlertType } from '@/constants/alerts';
|
import { AlertType } from '@/constants/alerts';
|
||||||
import { ButtonShape, ButtonSize } from '@/constants/buttons';
|
import { ButtonShape, ButtonSize } from '@/constants/buttons';
|
||||||
import { ERROR_STRING_KEYS } from '@/constants/localization/errors';
|
import { ERROR_STRING_KEYS } from '@/constants/localization/errors';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
import { CHAIN_IDS } from '@/constants/networks';
|
import { CLIENT_NETWORK_CONFIGS } from '@/constants/networks';
|
||||||
import { NumberSign, QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
import { NumberSign, QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
||||||
import { DYDX_CHAIN_ASSET_COIN_DENOM, DYDX_CHAIN_INFO, DydxChainAsset } from '@/constants/wallets';
|
import { DYDX_CHAIN_ASSET_COIN_DENOM, DYDX_CHAIN_INFO, DydxChainAsset } from '@/constants/wallets';
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ export const TransferForm = ({
|
|||||||
|
|
||||||
const networkOptions = [
|
const networkOptions = [
|
||||||
{
|
{
|
||||||
chainId: CHAIN_IDS[selectedNetwork],
|
chainId: CLIENT_NETWORK_CONFIGS[selectedNetwork].dydxChainId,
|
||||||
label: (
|
label: (
|
||||||
<Styled.InlineRow>
|
<Styled.InlineRow>
|
||||||
<AssetIcon symbol="DYDX" /> {stringGetter({ key: STRING_KEYS.DYDX_CHAIN })}
|
<AssetIcon symbol="DYDX" /> {stringGetter({ key: STRING_KEYS.DYDX_CHAIN })}
|
||||||
@@ -318,7 +318,7 @@ export const TransferForm = ({
|
|||||||
/>
|
/>
|
||||||
<Styled.NetworkSelectMenu
|
<Styled.NetworkSelectMenu
|
||||||
label={stringGetter({ key: STRING_KEYS.NETWORK })}
|
label={stringGetter({ key: STRING_KEYS.NETWORK })}
|
||||||
value={CHAIN_IDS[selectedNetwork]}
|
value={CLIENT_NETWORK_CONFIGS[selectedNetwork].dydxChainId}
|
||||||
slotTriggerAfter={null}
|
slotTriggerAfter={null}
|
||||||
>
|
>
|
||||||
{networkOptions.map(({ chainId, label }) => (
|
{networkOptions.map(({ chainId, label }) => (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||||
|
|
||||||
import { useSelectedNetwork } from '@/hooks';
|
import { useSelectedNetwork } from '@/hooks';
|
||||||
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
import { headerMixins } from '@/styles/headerMixins';
|
import { headerMixins } from '@/styles/headerMixins';
|
||||||
|
|
||||||
import { DropdownSelectMenu } from '@/components/DropdownSelectMenu';
|
import { DropdownSelectMenu } from '@/components/DropdownSelectMenu';
|
||||||
@@ -18,7 +19,6 @@ export const NetworkSelectMenu = ({ align, sideOffset }: StyleProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Styled.DropdownSelectMenu
|
<Styled.DropdownSelectMenu
|
||||||
disabled={import.meta.env.MODE === 'production'}
|
|
||||||
items={networks}
|
items={networks}
|
||||||
value={selectedNetwork}
|
value={selectedNetwork}
|
||||||
onValueChange={switchNetwork}
|
onValueChange={switchNetwork}
|
||||||
@@ -32,4 +32,11 @@ const Styled: Record<string, AnyStyledComponent> = {};
|
|||||||
|
|
||||||
Styled.DropdownSelectMenu = styled(DropdownSelectMenu)`
|
Styled.DropdownSelectMenu = styled(DropdownSelectMenu)`
|
||||||
${headerMixins.dropdownTrigger}
|
${headerMixins.dropdownTrigger}
|
||||||
|
|
||||||
|
& > span:first-of-type {
|
||||||
|
${layoutMixins.textOverflow}
|
||||||
|
max-width: 5.625rem;
|
||||||
|
min-width: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,45 +1,13 @@
|
|||||||
import { type MenuItem } from '@/constants/menus';
|
import { type MenuItem } from '@/constants/menus';
|
||||||
import { type DydxNetwork, DydxV3Network, DydxV4Network } from '@/constants/networks';
|
import { type DydxNetwork, NETWORK_ENDPOINTS } from '@/constants/networks';
|
||||||
|
import { useStringGetter } from '@/hooks';
|
||||||
|
|
||||||
export const useNetworks = (): MenuItem<DydxNetwork>[] =>
|
export const useNetworks = (): MenuItem<DydxNetwork>[] => {
|
||||||
import.meta.env.MODE === 'production'
|
const stringGetter = useStringGetter();
|
||||||
? [
|
|
||||||
{
|
return NETWORK_ENDPOINTS.environments.map(({ stringKey, environment }) => ({
|
||||||
value: DydxV4Network.V4Testnet2,
|
key: environment,
|
||||||
label: 'Testnet',
|
label: stringGetter({ key: stringKey }),
|
||||||
slotBefore: <b>v4</b>,
|
value: environment,
|
||||||
},
|
}));
|
||||||
]
|
};
|
||||||
: [
|
|
||||||
{
|
|
||||||
value: DydxV4Network.V4Mainnet,
|
|
||||||
label: 'Mainnet',
|
|
||||||
slotBefore: <b>v4</b>,
|
|
||||||
disabled: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: DydxV4Network.V4Staging,
|
|
||||||
label: 'Staging',
|
|
||||||
slotBefore: <b>v4</b>,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: DydxV4Network.V4Testnet2,
|
|
||||||
label: 'Testnet-2',
|
|
||||||
slotBefore: <b>v4</b>,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: DydxV4Network.V4Local,
|
|
||||||
label: 'Dev',
|
|
||||||
slotBefore: <b>v4</b>,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: DydxV3Network.V3Mainnet,
|
|
||||||
label: 'Mainnet',
|
|
||||||
slotBefore: <b>v3</b>,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: DydxV3Network.V3Testnet,
|
|
||||||
label: 'Testnet',
|
|
||||||
slotBefore: <b>v3</b>,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
import styled, { type AnyStyledComponent, css } from 'styled-components';
|
||||||
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
import type { ColumnSize } from '@react-types/table';
|
import type { ColumnSize } from '@react-types/table';
|
||||||
|
|
||||||
import { type Asset, type SubaccountFill } from '@/constants/abacus';
|
import { type Asset, type SubaccountFill } from '@/constants/abacus';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import styled, { type AnyStyledComponent, css, keyframes } from 'styled-components';
|
import styled, { type AnyStyledComponent, css, keyframes } from 'styled-components';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
|
|
||||||
import { MarketTrade } from '@/constants/abacus';
|
import { MarketTrade } from '@/constants/abacus';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import styled, { type AnyStyledComponent, css, keyframes } from 'styled-components';
|
import styled, { type AnyStyledComponent, css, keyframes } from 'styled-components';
|
||||||
|
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
import { type OrderbookLine, TradeInputField } from '@/constants/abacus';
|
import { type OrderbookLine, TradeInputField } from '@/constants/abacus';
|
||||||
import { STRING_KEYS } from '@/constants/localization';
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||||||
import styled, { css, type AnyStyledComponent } from 'styled-components';
|
import styled, { css, type AnyStyledComponent } from 'styled-components';
|
||||||
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { OrderSide } from '@dydxprotocol/v4-client';
|
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||||
import { ColumnSize } from '@react-types/table';
|
import { ColumnSize } from '@react-types/table';
|
||||||
import type { Dispatch } from '@reduxjs/toolkit';
|
import type { Dispatch } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user