Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67e7893629 | ||
|
|
24ffb19787 | ||
|
|
1386f5cd9e | ||
|
|
906faa554d | ||
|
|
c339eeccde | ||
|
|
bd03fb73ca | ||
|
|
31825a8a52 |
+2
-2
@@ -39,9 +39,9 @@
|
||||
"@cosmjs/proto-signing": "^0.31.0",
|
||||
"@cosmjs/stargate": "^0.31.0",
|
||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||
"@dydxprotocol/v4-abacus": "^1.0.10",
|
||||
"@dydxprotocol/v4-abacus": "^1.0.19",
|
||||
"@dydxprotocol/v4-client-js": "^1.0.0",
|
||||
"@dydxprotocol/v4-localization": "^1.0.0",
|
||||
"@dydxprotocol/v4-localization": "^1.0.5",
|
||||
"@ethersproject/providers": "^5.7.2",
|
||||
"@js-joda/core": "^5.5.3",
|
||||
"@radix-ui/react-collapsible": "^1.0.3",
|
||||
|
||||
Generated
+8
-8
@@ -27,14 +27,14 @@ dependencies:
|
||||
specifier: ^0.31.0
|
||||
version: 0.31.0
|
||||
'@dydxprotocol/v4-abacus':
|
||||
specifier: ^1.0.10
|
||||
version: 1.0.10
|
||||
specifier: ^1.0.19
|
||||
version: 1.0.19
|
||||
'@dydxprotocol/v4-client-js':
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
'@dydxprotocol/v4-localization':
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
specifier: ^1.0.5
|
||||
version: 1.0.5
|
||||
'@ethersproject/providers':
|
||||
specifier: ^5.7.2
|
||||
version: 5.7.2
|
||||
@@ -979,8 +979,8 @@ packages:
|
||||
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
||||
dev: true
|
||||
|
||||
/@dydxprotocol/v4-abacus@1.0.10:
|
||||
resolution: {integrity: sha512-SdxI/JcyxM1ydtR9ImWujeurea3gbxj37qYnw1wz829BQiZ05uNEtll3xJCI0MjpG+01ARsxVys7SHbpjSxwOg==}
|
||||
/@dydxprotocol/v4-abacus@1.0.19:
|
||||
resolution: {integrity: sha512-XhvSHGr503gNwHWEiOYP7M2uYeLu+Qm4szpE5w5H6hWFCanSGz6zAsTbPuyPLtt7IE1gj5z8mlL9J3tw2AZROg==}
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-client-js@1.0.0:
|
||||
@@ -1011,8 +1011,8 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-localization@1.0.0:
|
||||
resolution: {integrity: sha512-U7QjOlzpfSAVEchkNDB3xYRx7okzdeYi83XsnHwI+EHa2quFm/2Y2dhrBkT5fqpZmhcwxb/vG8AZmFSToOf9hA==}
|
||||
/@dydxprotocol/v4-localization@1.0.5:
|
||||
resolution: {integrity: sha512-zZm3GFp/ORz9YjigQFVBlcWmaxYY+XEdIw8AWN5nEbsuiA2Jay+/OA7lO9+nV1J1p1T+TgLo9iczIHJsAo3IsA==}
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-proto@0.4.1:
|
||||
|
||||
@@ -400,6 +400,76 @@
|
||||
"signTypedDataDomainName": "dYdX Chain"
|
||||
}
|
||||
},
|
||||
"dydxprotocol-staging-forced-update": {
|
||||
"name": "v4 Staging Forced Update",
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
"chain": {
|
||||
"name": "Dv4TNT",
|
||||
"denom": "adv4tnt",
|
||||
"decimals": 18,
|
||||
"image": "/currencies/dydx.png"
|
||||
},
|
||||
"usdc": {
|
||||
"name": "USDC",
|
||||
"denom": "ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5",
|
||||
"gasDenom": "uusdc",
|
||||
"decimals": 6,
|
||||
"image": "/currencies/usdc.png"
|
||||
}
|
||||
},
|
||||
"endpoints": {
|
||||
"indexers": [
|
||||
{
|
||||
"api": "https://indexer.v4staging.dydx.exchange",
|
||||
"socket": "wss://indexer.v4staging.dydx.exchange"
|
||||
}
|
||||
],
|
||||
"faucet": "https://faucet.v4staging.dydx.exchange",
|
||||
"validators": [
|
||||
"https://validator.v4staging.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
"privacy": "https://dydx.exchange/privacy",
|
||||
"mintscan": "https://testnet.mintscan.io/dydx-testnet/txs/{tx_hash}",
|
||||
"documentation": "https://v4-teacher.vercel.app/",
|
||||
"community": "https://discord.com/invite/dydx",
|
||||
"feedback": "https://docs.google.com/forms/d/e/1FAIpQLSezLsWCKvAYDEb7L-2O4wOON1T56xxro9A2Azvl6IxXHP_15Q/viewform",
|
||||
"blogs": "https://www.dydx.foundation/blog"
|
||||
},
|
||||
"wallets": {
|
||||
"walletconnect": {
|
||||
"client": {
|
||||
"name": "dYdX v4",
|
||||
"description": "dYdX v4 App",
|
||||
"iconUrl": "/logos/dydx-x.png"
|
||||
},
|
||||
"v2": {
|
||||
"projectId": "47559b2ec96c09aed9ff2cb54a31ab0e"
|
||||
}
|
||||
},
|
||||
"walletSegue": {
|
||||
"callbackUrl": "/walletsegue"
|
||||
},
|
||||
"images": "/wallets/",
|
||||
"signTypedDataAction": "dYdX Chain Onboarding",
|
||||
"signTypedDataDomainName": "dYdX Chain"
|
||||
},
|
||||
"apps": {
|
||||
"ios": {
|
||||
"minimalVersion": "1.0",
|
||||
"build":40000,
|
||||
"url": "https://apps.apple.com/app/dydx/id1564787350"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dydxprotocol-staging-west": {
|
||||
"name": "v4 Staging West",
|
||||
"ethereumChainId": "5",
|
||||
|
||||
@@ -42,6 +42,7 @@ const useAccountsContext = () => {
|
||||
selectedWalletError,
|
||||
evmAddress,
|
||||
signerWagmi,
|
||||
publicClientWagmi,
|
||||
dydxAddress: connectedDydxAddress,
|
||||
signerGraz,
|
||||
} = useWalletConnection();
|
||||
@@ -296,6 +297,7 @@ const useAccountsContext = () => {
|
||||
// Wallet connection (EVM)
|
||||
evmAddress,
|
||||
signerWagmi,
|
||||
publicClientWagmi,
|
||||
|
||||
// Wallet connection (Cosmos)
|
||||
signerGraz,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useState, useMemo } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { LocalStorageKey } from '@/constants/localStorage';
|
||||
@@ -90,19 +90,21 @@ export const useWalletConnection = () => {
|
||||
|
||||
const selectedNetwork = useSelector(getSelectedNetwork);
|
||||
const walletConnectConfig = ENVIRONMENT_CONFIG_MAP[selectedNetwork].wallets.walletconnect;
|
||||
|
||||
const { connectAsync: connectWagmi } =
|
||||
walletType && walletConnectionType
|
||||
? useConnectWagmi({
|
||||
connector: resolveWagmiConnector({
|
||||
const wagmiConnector = useMemo(
|
||||
() =>
|
||||
walletType && walletConnectionType
|
||||
? resolveWagmiConnector({
|
||||
walletType,
|
||||
walletConnection: {
|
||||
type: walletConnectionType,
|
||||
},
|
||||
walletConnectConfig,
|
||||
}),
|
||||
})
|
||||
: useConnectWagmi();
|
||||
})
|
||||
: undefined,
|
||||
[walletConnectConfig, walletType, walletConnectionType]
|
||||
);
|
||||
|
||||
const { connectAsync: connectWagmi } = useConnectWagmi({ connector: wagmiConnector })
|
||||
const { suggestAndConnect: connectGraz } = useConnectGraz();
|
||||
|
||||
const connectWallet = useCallback(
|
||||
|
||||
@@ -236,4 +236,5 @@ Styled.IconButton = styled(IconButton)<{ size?: string }>`
|
||||
${headerMixins.button}
|
||||
--button-border: none;
|
||||
--button-icon-size: 1rem;
|
||||
--button-padding: 0 0.5em;
|
||||
`;
|
||||
|
||||
@@ -48,6 +48,15 @@ export const getTradeInputErrors = (state: RootState) => {
|
||||
return currentInput === 'trade' ? getInputErrors(state) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns input errors for Close position
|
||||
*/
|
||||
export const getClosePositionInputErrors = (state: RootState) => {
|
||||
const currentInput = state.inputs.current;
|
||||
return currentInput === 'closePosition' ? getInputErrors(state) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns input errors for Transfer
|
||||
|
||||
@@ -34,7 +34,7 @@ export const TransferStatusToast = ({
|
||||
}: ElementProps) => {
|
||||
const stringGetter = useStringGetter();
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const [secondsLeft, setSecondsLeft] = useState<number | undefined>();
|
||||
const [secondsLeft, setSecondsLeft] = useState<number>(0);
|
||||
|
||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
||||
@@ -49,14 +49,23 @@ export const TransferStatusToast = ({
|
||||
|
||||
if (!status) return <LoadingDots size={3} />;
|
||||
|
||||
const inProgressStatusString =
|
||||
type === 'deposit'
|
||||
? secondsLeft > 0
|
||||
? STRING_KEYS.DEPOSIT_STATUS
|
||||
: STRING_KEYS.DEPOSIT_STATUS_SHORTLY
|
||||
: secondsLeft > 0
|
||||
? STRING_KEYS.WITHDRAW_STATUS
|
||||
: STRING_KEYS.WITHDRAW_STATUS_SHORTLY;
|
||||
|
||||
const statusString =
|
||||
type === 'deposit'
|
||||
? status?.squidTransactionStatus === 'success'
|
||||
? STRING_KEYS.DEPOSIT_COMPLETE
|
||||
: STRING_KEYS.DEPOSIT_STATUS
|
||||
: inProgressStatusString
|
||||
: status?.squidTransactionStatus === 'success'
|
||||
? STRING_KEYS.WITHDRAW_COMPLETE
|
||||
: STRING_KEYS.WITHDRAW_STATUS;
|
||||
: inProgressStatusString;
|
||||
|
||||
return (
|
||||
<Styled.Root open={open} onOpenChange={setOpen}>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import styled, { css, keyframes, type AnyStyledComponent } from 'styled-components';
|
||||
import { StatusResponse } from '@0xsquid/sdk';
|
||||
|
||||
import { useStringGetter } from '@/hooks';
|
||||
import { useStringGetter, useSelectedNetwork, useURLConfigs } from '@/hooks';
|
||||
|
||||
import { Link } from '@/components/Link';
|
||||
import { Icon, IconName } from '@/components/Icon';
|
||||
@@ -11,6 +11,7 @@ import { LoadingSpinner } from '@/components/Loading/LoadingSpinner';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
||||
|
||||
type ElementProps = {
|
||||
status?: StatusResponse;
|
||||
@@ -26,12 +27,17 @@ enum TransferStatusStep {
|
||||
|
||||
export const TransferStatusSteps = ({ status, type }: ElementProps) => {
|
||||
const stringGetter = useStringGetter();
|
||||
const { selectedNetwork } = useSelectedNetwork();
|
||||
const { mintscan: mintscanTxUrl } = useURLConfigs();
|
||||
const dydxChainId = ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId;
|
||||
|
||||
const { currentStep, steps } = useMemo(() => {
|
||||
const routeStatus = status?.routeStatus;
|
||||
const fromChain = status?.fromChain?.chainData?.chainId;
|
||||
const toChain = status?.toChain?.chainData?.chainId;
|
||||
|
||||
const currentStatus = routeStatus?.[routeStatus?.length - 1];
|
||||
|
||||
const steps = [
|
||||
{
|
||||
label: stringGetter({
|
||||
@@ -54,12 +60,15 @@ export const TransferStatusSteps = ({ status, type }: ElementProps) => {
|
||||
},
|
||||
}),
|
||||
step: TransferStatusStep.ToChain,
|
||||
link: status?.toChain?.transactionUrl,
|
||||
link:
|
||||
type === 'withdrawal'
|
||||
? status?.toChain?.transactionUrl
|
||||
: currentStatus?.chainId === dydxChainId && currentStatus?.txHash
|
||||
? `${mintscanTxUrl?.replace('{tx_hash}', currentStatus.txHash)}`
|
||||
: undefined,
|
||||
},
|
||||
];
|
||||
|
||||
const currentStatus = routeStatus?.[routeStatus?.length - 1];
|
||||
|
||||
let currentStep = TransferStatusStep.Bridge;
|
||||
|
||||
if (!routeStatus?.length) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import { useAccounts, useDebounce, useStringGetter, useSelectedNetwork } from '@
|
||||
import { useAccountBalance, CHAIN_DEFAULT_TOKEN_ADDRESS } from '@/hooks/useAccountBalance';
|
||||
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
||||
import { NATIVE_TOKEN_ADDRESS, useSquid } from '@/hooks/useSquid';
|
||||
import { useWalletConnection } from '@/hooks/useWalletConnection';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { formMixins } from '@/styles/formMixins';
|
||||
@@ -56,8 +55,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { selectedNetwork } = useSelectedNetwork();
|
||||
|
||||
const { evmAddress, signerWagmi } = useAccounts();
|
||||
const { publicClientWagmi } = useWalletConnection();
|
||||
const { evmAddress, signerWagmi, publicClientWagmi } = useAccounts();
|
||||
|
||||
const { addTransferNotification } = useLocalNotifications();
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import {
|
||||
ClosePositionInputField,
|
||||
ValidationError,
|
||||
type HumanReadablePlaceOrderPayload,
|
||||
type Nullable,
|
||||
ErrorType,
|
||||
} from '@/constants/abacus';
|
||||
import { AlertType } from '@/constants/alerts';
|
||||
import { ButtonAction, ButtonShape, ButtonSize, ButtonType } from '@/constants/buttons';
|
||||
@@ -35,13 +37,14 @@ import { PositionPreview } from '@/views/forms/TradeForm/PositionPreview';
|
||||
import { getCurrentMarketPositionData } from '@/state/accountSelectors';
|
||||
|
||||
import { getCurrentMarketAssetData } from '@/state/assetsSelectors';
|
||||
import { getInputClosePositionData } from '@/state/inputsSelectors';
|
||||
import { getClosePositionInputErrors, getInputClosePositionData } from '@/state/inputsSelectors';
|
||||
import { getCurrentMarketConfig, getCurrentMarketId } from '@/state/perpetualsSelectors';
|
||||
import { closeDialog } from '@/state/dialogs';
|
||||
import { getCurrentInput } from '@/state/inputsSelectors';
|
||||
|
||||
import abacusStateManager from '@/lib/abacus';
|
||||
import { MustBigNumber } from '@/lib/numbers';
|
||||
import { getTradeInputAlert } from '@/lib/tradeData';
|
||||
|
||||
const MAX_KEY = 'MAX';
|
||||
|
||||
@@ -81,15 +84,38 @@ export const ClosePositionForm = ({
|
||||
|
||||
const market = useSelector(getCurrentMarketId);
|
||||
const { id } = useSelector(getCurrentMarketAssetData, shallowEqual) || {};
|
||||
const { stepSizeDecimals } = useSelector(getCurrentMarketConfig, shallowEqual) || {};
|
||||
const { stepSizeDecimals, tickSizeDecimals } =
|
||||
useSelector(getCurrentMarketConfig, shallowEqual) || {};
|
||||
const { size: sizeData, summary } = useSelector(getInputClosePositionData, shallowEqual) || {};
|
||||
const { size, percent } = sizeData || {};
|
||||
const currentInput = useSelector(getCurrentInput);
|
||||
const closePositionInputErrors = useSelector(getClosePositionInputErrors, shallowEqual);
|
||||
const currentPositionData = useSelector(getCurrentMarketPositionData, shallowEqual);
|
||||
const { size: currentPositionSize } = currentPositionData || {};
|
||||
const { current: currentSize } = currentPositionSize || {};
|
||||
const currentSizeBN = MustBigNumber(currentSize).abs();
|
||||
|
||||
const hasInputErrors = closePositionInputErrors?.some(
|
||||
(error: ValidationError) => error.type !== ErrorType.warning
|
||||
);
|
||||
|
||||
const inputAlert = getTradeInputAlert({
|
||||
abacusInputErrors: closePositionInputErrors ?? [],
|
||||
stringGetter,
|
||||
stepSizeDecimals,
|
||||
tickSizeDecimals,
|
||||
});
|
||||
|
||||
let alertContent;
|
||||
let alertType = AlertType.Error;
|
||||
|
||||
if (closePositionError) {
|
||||
alertContent = closePositionError;
|
||||
} else if (inputAlert) {
|
||||
alertContent = inputAlert?.alertString;
|
||||
alertType = inputAlert?.type;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (currentStep && currentStep !== MobilePlaceOrderSteps.EditOrder) return;
|
||||
|
||||
@@ -182,9 +208,7 @@ export const ClosePositionForm = ({
|
||||
});
|
||||
};
|
||||
|
||||
const alertMessage = closePositionError && (
|
||||
<AlertMessage type={AlertType.Error}>{closePositionError}</AlertMessage>
|
||||
);
|
||||
const alertMessage = alertContent && <AlertMessage type={alertType}>{alertContent}</AlertMessage>;
|
||||
|
||||
const inputs = (
|
||||
<Styled.InputsColumn>
|
||||
@@ -265,8 +289,8 @@ export const ClosePositionForm = ({
|
||||
|
||||
<PlaceOrderButtonAndReceipt
|
||||
isLoading={isClosingPosition}
|
||||
hasValidationErrors={!size}
|
||||
actionStringKey={!size ? STRING_KEYS.ENTER_AMOUNT : undefined}
|
||||
hasValidationErrors={hasInputErrors}
|
||||
actionStringKey={inputAlert?.actionStringKey}
|
||||
summary={summary ?? undefined}
|
||||
currentStep={currentStep}
|
||||
isClosePosition
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ButtonAction } from '@/constants/buttons';
|
||||
import { DialogTypes } from '@/constants/dialogs';
|
||||
import { STRING_KEYS, StringGetterFunction } from '@/constants/localization';
|
||||
|
||||
import { useBreakpoints, useStringGetter } from '@/hooks';
|
||||
import { useBreakpoints, useStringGetter, useURLConfigs } from '@/hooks';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { tradeViewMixins } from '@/styles/tradeViewMixins';
|
||||
@@ -40,11 +40,13 @@ const getTransferHistoryTableColumnDef = ({
|
||||
key,
|
||||
stringGetter,
|
||||
width,
|
||||
mintscanTxUrl,
|
||||
}: {
|
||||
key: TransferHistoryTableColumnKey;
|
||||
isTablet?: boolean;
|
||||
stringGetter: StringGetterFunction;
|
||||
width?: ColumnSize;
|
||||
mintscanTxUrl?: string;
|
||||
}): ColumnDef<SubaccountTransfer> => ({
|
||||
width,
|
||||
...(
|
||||
@@ -98,9 +100,12 @@ const getTransferHistoryTableColumnDef = ({
|
||||
columnKey: TransferHistoryTableColumnKey.TxHash,
|
||||
getCellValue: (row) => row.transactionHash,
|
||||
label: stringGetter({ key: STRING_KEYS.TRANSACTION }),
|
||||
renderCell: ({ transactionHash, resources }) =>
|
||||
renderCell: ({ transactionHash }) =>
|
||||
transactionHash ? (
|
||||
<Styled.TxHash withIcon href={resources.blockExplorerUrl}>
|
||||
<Styled.TxHash
|
||||
withIcon
|
||||
href={`${mintscanTxUrl?.replace('{tx_hash}', transactionHash)}`}
|
||||
>
|
||||
{truncateAddress(transactionHash, '')}
|
||||
</Styled.TxHash>
|
||||
) : (
|
||||
@@ -130,6 +135,7 @@ export const TransferHistoryTable = ({
|
||||
const stringGetter = useStringGetter();
|
||||
const dispatch = useDispatch();
|
||||
const { isMobile, isTablet } = useBreakpoints();
|
||||
const { mintscan: mintscanTxUrl } = useURLConfigs();
|
||||
|
||||
const canAccountTrade = useSelector(calculateCanAccountTrade, shallowEqual);
|
||||
|
||||
@@ -146,6 +152,7 @@ export const TransferHistoryTable = ({
|
||||
isTablet,
|
||||
stringGetter,
|
||||
width: columnWidths?.[key],
|
||||
mintscanTxUrl,
|
||||
})
|
||||
)}
|
||||
slotEmpty={
|
||||
|
||||
Reference in New Issue
Block a user