Compare commits

..
Author SHA1 Message Date
Bill He 8c3f867f06 Learnmore -> LearnMore 2023-10-31 10:58:33 -07:00
Bill He 1a95814925 add learnmore to tooltip 2023-10-31 10:57:21 -07:00
Bill He a6d7a5cb4e Configurable URLs 2023-10-31 10:57:20 -07:00
38 changed files with 326 additions and 540 deletions
+3 -7
View File
@@ -4,11 +4,7 @@ VITE_ALCHEMY_API_KEY=
VITE_PK_ENCRYPTION_KEY=
VITE_V3_TOKEN_ADDRESS=
VITE_TOKEN_MIGRATION_URI=
VITE_WALLETCONNECT2_PROJECT_ID=
AMPLITUDE_API_KEY=
BUGSNAG_API_KEY=
IOS_APP_ID=
INTERCOM_APP_ID=
STATUS_PAGE_SCRIPT_URI=
VITE_V3_TOKEN_ADDRESS=
VITE_TOKEN_MIGRATION_URI=
+1 -4
View File
@@ -1,9 +1,6 @@
Copyright (C) 2023 dYdX Trading Inc.
Subject to your compliance with applicable law and the v4 Terms of Use, available at dydx.exchange/legal, you are granted the right to use the Program or Licensed Work (defined below) under the terms of the GNU Affero General Public License as set forth below; provided, however, that if you violate any such applicable law in your use of the Program or Licensed Work, all of your rights and licenses to use (including any rights to reproduce, distribute, install or modify) the Program or Licensed Work will automatically and immediately terminate.
The “Program” or “Licensed Work” shall mean any of the following: dydxprotocol/cosmos-sdk, dydxprotocol/cometbft, dydxprotocol/v4-chain, dydxprotocol/v4-clients, dydxprotocol/v4-web, dydxprotocol/v4-abacus, dydxprotocol/v4-localization, dydxprotocol/v4-documentation, and any dYdX or dYdX Trading Inc. repository reflecting a copy of, or link to, this license.
Subject to your compliance with applicable law, you are granted the right to use the Licensed Work (defined below) under the terms of the GNU Affero General Public License as set forth below; provided, however, that if you violate any such applicable law in your use of the Licensed Work, all of your rights and licenses to use (including any rights to reproduce, distribute, install or modify) the Licensed Work will automatically and immediately terminate.
The GNU Affero General Public License
-15
View File
@@ -69,21 +69,6 @@ You'll need to provide a Wallet Connect project id to enable onboarding and wall
- Create a project on https://cloud.walletconnect.com/app
- Copy over the project ID into this [field](https://github.com/dydxprotocol/v4-web/blob/67ecbd75b43e0c264b7b4d2d9b3d969830b0621c/public/configs/env.json#L822C33-L822C46)
## Part 4: Set Enviornment variables
Set environment variables via `.env`.
- `VITE_BASE_URL` (required): The base URL of the deployment (e.g., `https://www.example.com`).
- `VITE_ALCHEMY_API_KEY` (optional): Add an Alchemy API key for EVM interactions; the app will fall back to public RPCs if not provided.
- `VITE_PK_ENCRYPTION_KEY` (optional): AES encryption key used for signature obfuscation; necessary for enabling the "Remember Me" feature.
- `VITE_V3_TOKEN_ADDRESS` (optional): Address of the V3 $DYDX token.
- `VITE_TOKEN_MIGRATION_URI` (optional): The URL of the token migration website.
- `AMPLITUDE_API_KEY` (optional): Amplitude API key for enabling Amplitude; used with `pnpm run build:inject-amplitude`.
- `BUGSNAG_API_KEY` (optional): API key for enabling Bugsnag; used with `pnpm run build:inject-bugsnag`.
- `IOS_APP_ID` (optional): iOS app ID used for enabling deep linking to the iOS app; used with `pnpm run build:inject-app-deeplinks`.
- `INTERCOM_APP_ID` (optional): Used for enabling Intercom; utilized with `pnpm run build:inject-intercom`.
- `STATUS_PAGE_SCRIPT_URI` (optional): Used for enabling the status page; used with `pnpm run build:inject-statuspage`.
# Deployments
## Deploying with Vercel
+1 -1
View File
@@ -39,7 +39,7 @@
"@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.3",
"@dydxprotocol/v4-client-js": "^1.0.0",
"@dydxprotocol/v4-localization": "^1.0.0",
"@ethersproject/providers": "^5.7.2",
+11 -11
View File
@@ -1,9 +1,5 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@0xsquid/sdk':
specifier: ^1.10.0
@@ -27,8 +23,8 @@ dependencies:
specifier: ^0.31.0
version: 0.31.0
'@dydxprotocol/v4-abacus':
specifier: ^1.0.10
version: 1.0.10
specifier: ^1.0.3
version: 1.0.3
'@dydxprotocol/v4-client-js':
specifier: ^1.0.0
version: 1.0.0
@@ -979,8 +975,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.3:
resolution: {integrity: sha512-GuX37/DMMNSke8ZFcw52II7IVJfUgVGHqoi1Uw2cUb+hgIjjSG3OtbyRWedm5r6nqWq8BNLOexI0VVFB6OMVYg==}
dev: false
/@dydxprotocol/v4-client-js@1.0.0:
@@ -7656,7 +7652,7 @@ packages:
resolution: {integrity: sha512-WIdaQ8uW1vIbYvNnAVunkC6yxTrneJC7VQ5UUQ0kuw8b0C0A39KTIpoQHCfc8tV7o9vF4niwRhdXEdfAgQEsQQ==}
dependencies:
cosmos-directory-types: 0.0.6
node-fetch-native: 1.4.1
node-fetch-native: 1.4.0
dev: false
/cosmos-directory-types@0.0.6:
@@ -11287,8 +11283,8 @@ packages:
engines: {node: '>=10.5.0'}
dev: true
/node-fetch-native@1.4.1:
resolution: {integrity: sha512-NsXBU0UgBxo2rQLOeWNZqS3fvflWePMECr8CoSWoSTqCqGbVVsvl9vZu1HfQicYN0g5piV9Gh8RTEvo/uP752w==}
/node-fetch-native@1.4.0:
resolution: {integrity: sha512-F5kfEj95kX8tkDhUCYdV8dg3/8Olx/94zB8+ZNthFs6Bz31UpUi8Xh40TN3thLwXgrwXry1pEg9lJ++tLWTcqA==}
dev: false
/node-fetch@2.6.12:
@@ -14100,3 +14096,7 @@ packages:
/zwitch@2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
+2 -21
View File
@@ -1,9 +1,4 @@
{
"apps": {
"iOS": {
"scheme": "dydxv4"
}
},
"deployments": {
"MAINNET": {
"environments": [
@@ -43,7 +38,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -116,7 +110,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -188,7 +181,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -208,8 +200,8 @@
"endpoints": {
"indexers": [
{
"api": "https://indexer.v4dev4.dydx.exchange",
"socket": "wss://indexer.v4dev4.dydx.exchange"
"api": "http://indexer.v4dev4.dydx.exchange",
"socket": "ws://indexer.v4dev4.dydx.exchange"
}
],
"validators": [
@@ -260,7 +252,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -332,7 +323,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -406,7 +396,6 @@
"dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -480,7 +469,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -558,7 +546,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -633,7 +620,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -708,7 +694,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -783,7 +768,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -858,7 +842,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -923,7 +906,6 @@
"dydxChainId": "dydx-testnet-4",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "dYdX-api",
"isMainNet": false,
"tokens": {
"chain": {
@@ -998,7 +980,6 @@
"dydxChainId": "[mainnet chain id]",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"squidIntegratorId": "[mainnet squid integrator id]",
"isMainNet": true,
"tokens": {
"comment": "Change according to mainnet release",
-1
View File
@@ -225,7 +225,6 @@ Styled.CollapsibleContent = styled(CollapsibleContent)`
`;
Styled.IconButton = styled(IconButton)`
--button-icon-size: 1em;
${Styled.CollapsibleRoot}[data-state='closed'] & {
rotate: -0.5turn;
}
-3
View File
@@ -34,7 +34,6 @@ type PickDialogProps = Pick<
| 'slotHeaderInner'
| 'slotTrigger'
| 'slotFooter'
| 'preventClose'
>;
export const ComboboxDialogMenu = <
@@ -58,7 +57,6 @@ export const ComboboxDialogMenu = <
children,
placement = DialogPlacement.Default,
preventClose,
className,
}: ElementProps<MenuItemValue, MenuGroupValue> &
PickComboxMenuProps<MenuItemValue, MenuGroupValue> &
@@ -74,7 +72,6 @@ export const ComboboxDialogMenu = <
slotTrigger={slotTrigger}
slotFooter={slotFooter}
placement={placement}
preventClose={preventClose}
className={className}
>
<Styled.ComboboxMenu
+1 -3
View File
@@ -33,11 +33,9 @@ export const DropdownHeaderMenu = <MenuItemValue extends string>({
return (
<Root>
<Styled.Trigger className={className} asChild>
<div>
<Styled.Trigger className={className}>
{children}
<Styled.DropdownIconButton iconName={IconName.Caret} isToggle />
</div>
</Styled.Trigger>
<Portal>
<Styled.Content
+1 -7
View File
@@ -24,10 +24,9 @@ import {
CommentIcon,
CopyIcon,
CubeIcon,
DepositIcon,
DepthChartIcon,
DiscordIcon,
EtherscanIcon,
DepthChartIcon,
ExportKeysIcon,
FeedbackIcon,
FileIcon,
@@ -70,7 +69,6 @@ import {
WarningIcon,
WebsiteIcon,
WhitepaperIcon,
WithdrawIcon,
} from '@/icons';
export enum IconName {
@@ -95,7 +93,6 @@ export enum IconName {
Comment = 'Comment',
Copy = 'Copy',
Cube = 'Cube',
Deposit = 'Deposit',
DepthChart = 'DepthChart',
Discord = 'Discord',
Etherscan = 'Etherscan',
@@ -142,7 +139,6 @@ export enum IconName {
Warning = 'Warning',
Website = 'Website',
Whitepaper = 'Whitepaper',
Withdraw = 'Withdraw',
}
const icons = {
@@ -167,7 +163,6 @@ const icons = {
[IconName.Comment]: CommentIcon,
[IconName.Copy]: CopyIcon,
[IconName.Cube]: CubeIcon,
[IconName.Deposit]: DepositIcon,
[IconName.DepthChart]: DepthChartIcon,
[IconName.Discord]: DiscordIcon,
[IconName.Etherscan]: EtherscanIcon,
@@ -213,7 +208,6 @@ const icons = {
[IconName.Warning]: WarningIcon,
[IconName.Website]: WebsiteIcon,
[IconName.Whitepaper]: WhitepaperIcon,
[IconName.Withdraw]: WithdrawIcon,
} as Record<IconName, ElementType>;
type ElementProps = {
-1
View File
@@ -67,7 +67,6 @@ const Styled: Record<string, AnyStyledComponent> = {};
const buttonMixin = css`
// Params
--button-icon-size: 1.125em;
--button-padding: 0;
// Rules
> * {
+2 -2
View File
@@ -71,7 +71,7 @@ const NavItem = forwardRef(
)}
</span>
{slotAfter}
{subitems?.length && <Styled.Icon iconName={IconName.Triangle} />}
{subitems?.length && <Styled.Icon iconName={IconName.Caret} />}
</>
);
@@ -525,7 +525,7 @@ Styled.NavItem = styled(NavItem)<{ orientation: 'horizontal' | 'vertical' }>`
`;
Styled.Icon = styled(Icon)`
font-size: 0.375em;
height: 0.75em;
transition: rotate 0.3s var(--ease-out-expo);
${Styled.List}[data-orientation="menu"] & {
+5 -23
View File
@@ -31,7 +31,7 @@ export const Panel = ({
hasSeparator,
className,
}: PanelProps & PanelStyleProps) => (
<Styled.Panel onClick={onClick} className={className}>
<Styled.Panel onClick={onClick}>
<Styled.Left>
{href ? (
<Link to={href}>
@@ -53,7 +53,7 @@ export const Panel = ({
</Styled.Header>
)
)}
<Styled.Content>{children}</Styled.Content>
<Styled.Content className={className}>{children}</Styled.Content>
</Styled.Left>
{slotRight}
</Styled.Panel>
@@ -61,29 +61,11 @@ export const Panel = ({
const Styled: Record<string, AnyStyledComponent> = {};
Styled.Panel = styled.section<{ onClick?: () => void }>`
--panel-paddingY: 1rem;
--panel-paddingX: 1rem;
--panel-content-paddingY: var(--panel-paddingY);
--panel-content-paddingX: var(--panel-paddingX);
Styled.Panel = styled.section`
${layoutMixins.row}
background-color: var(--color-layer-3);
border-radius: 0.875rem;
${({ onClick }) =>
onClick &&
css`
cursor: pointer;
&:hover {
button:not(:disabled) {
color: var(--button-hover-textColor);
filter: var(--button-hover-filter);
}
}
`}
`;
Styled.Left = styled.div`
@@ -93,7 +75,7 @@ Styled.Left = styled.div`
Styled.Header = styled.header<{ hasSeparator?: boolean }>`
${layoutMixins.spacedRow}
padding: var(--panel-paddingY) var(--panel-paddingX);
padding: 1rem 1rem;
${({ hasSeparator }) =>
hasSeparator &&
@@ -112,5 +94,5 @@ Styled.Content = styled.div`
${layoutMixins.scrollArea}
${layoutMixins.stickyArea0}
--stickyArea0-background: transparent;
padding: var(--panel-content-paddingY) var(--panel-content-paddingX);
padding: 1rem 1rem;
`;
+4 -15
View File
@@ -7,15 +7,13 @@ import { ButtonShape, ButtonSize } from '@/constants/buttons';
import { useBreakpoints } from '@/hooks';
import { layoutMixins } from '@/styles/layoutMixins';
import { type BaseButtonProps } from '@/components/BaseButton';
import { type BaseButtonProps } from '@/components/BaseButton';
import { ToggleButton } from '@/components/ToggleButton';
type ElementProps<MenuItemValue extends string> = {
items: MenuItem<MenuItemValue>[];
value: MenuItemValue;
onValueChange: (value: any) => void;
onInteraction?: () => void;
ensureSelected?: boolean;
onValueChange: (value: MenuItemValue) => void;
};
type StyleProps = {
@@ -27,14 +25,10 @@ export const ToggleGroup = forwardRef(
{
items,
value,
ensureSelected = true,
onValueChange,
onInteraction,
className,
size,
shape = ButtonShape.Pill,
...buttonProps
}: ElementProps<MenuItemValue> & StyleProps & BaseButtonProps,
ref: Ref<HTMLDivElement>
@@ -46,17 +40,12 @@ export const ToggleGroup = forwardRef(
ref={ref}
type="single"
value={value}
onValueChange={(newValue: MenuItemValue) => {
if ((ensureSelected && newValue) || !ensureSelected) {
onValueChange(newValue);
}
onInteraction?.();
}}
onValueChange={onValueChange}
className={className}
loop
>
{items.map((item) => (
<Item key={item.value} value={item.value} asChild>
<Item key={item.value} value={item.value} aria-label={item.label} asChild>
<ToggleButton
size={size ? size : isTablet ? ButtonSize.Small : ButtonSize.XSmall}
shape={shape}
+8 -12
View File
@@ -6,10 +6,8 @@ import { MarketFilters, MARKET_FILTER_LABELS, type MarketData } from '@/constant
import { getAssets } from '@/state/assetsSelectors';
import { getPerpetualMarkets } from '@/state/perpetualsSelectors';
import { isTruthy } from '@/lib/isTruthy';
const filterFunctions = {
[MarketFilters.ALL]: () => true,
[MarketFilters.ALL]: (market: MarketData) => true,
[MarketFilters.LAYER_1]: (market: MarketData) => {
return market.asset.tags?.toArray().includes('Layer 1');
},
@@ -30,15 +28,13 @@ export const useMarketsData = (
const allAssets = useSelector(getAssets, shallowEqual) || {};
const markets = useMemo(() => {
return Object.values(allPerpetualMarkets)
.filter(isTruthy)
.map((marketData) => ({
asset: allAssets[marketData.assetId],
tickSizeDecimals: marketData.configs?.tickSizeDecimals,
...marketData,
...marketData.perpetual,
...marketData.configs,
})) as MarketData[];
return Object.values(allPerpetualMarkets).map((marketData) => ({
asset: allAssets[marketData.assetId],
tickSizeDecimals: marketData.configs?.tickSizeDecimals,
...marketData,
...marketData.perpetual,
...marketData.configs,
})) as MarketData[];
}, [allPerpetualMarkets, allAssets]);
const filteredMarkets = useMemo(() => {
+1 -5
View File
@@ -22,11 +22,7 @@ const useSquidContext = () => {
};
const squid = useMemo(
() =>
new Squid({
baseUrl: ENVIRONMENT_CONFIG_MAP[selectedNetwork]?.endpoints['0xsquid'],
integratorId: ENVIRONMENT_CONFIG_MAP[selectedNetwork]?.squidIntegratorId,
}),
() => new Squid({ baseUrl: ENVIRONMENT_CONFIG_MAP[selectedNetwork]?.endpoints['0xsquid'] }),
[selectedNetwork]
);
+54 -91
View File
@@ -48,7 +48,7 @@ export const useSubaccount = () => useContext(SubaccountContext);
export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: LocalWallet }) => {
const dispatch = useDispatch();
const { usdcDenom, usdcDecimals } = useTokenConfigs();
const { usdcDenom } = useTokenConfigs();
const { compositeClient, faucetClient } = useDydxClient();
const { getFaucetFunds } = useMemo(
@@ -79,34 +79,16 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
subaccountClient: SubaccountClient;
assetId?: number;
amount: number;
}) => {
try {
return await compositeClient?.depositToSubaccount(
subaccountClient,
amount.toFixed(usdcDecimals)
);
} catch (error) {
log('useSubaccount/depositToSubaccount', error);
throw error;
}
},
}) => await compositeClient?.depositToSubaccount(subaccountClient, amount.toString()),
withdrawFromSubaccount: async ({
subaccountClient,
amount,
}: {
subaccountClient: SubaccountClient;
amount: number;
}) => {
try {
return await compositeClient?.withdrawFromSubaccount(
subaccountClient,
amount.toFixed(usdcDecimals)
);
} catch (error) {
log('useSubaccount/withdrawFromSubaccount', error);
throw error;
}
},
}) => await compositeClient?.withdrawFromSubaccount(subaccountClient, amount.toString()),
transferFromSubaccountToAddress: async ({
subaccountClient,
assetId = 0,
@@ -117,33 +99,27 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
assetId?: number;
amount: number;
recipient: string;
}) => {
try {
return await compositeClient?.validatorClient.post.send(
subaccountClient?.wallet,
() =>
new Promise((resolve) => {
const msg =
compositeClient?.validatorClient.post.composer.composeMsgWithdrawFromSubaccount(
subaccountClient.address,
subaccountClient.subaccountNumber,
assetId,
Long.fromNumber(amount * QUANTUM_MULTIPLIER),
recipient
);
}) =>
await compositeClient?.validatorClient.post.send(
subaccountClient?.wallet,
() =>
new Promise((resolve) => {
const msg =
compositeClient?.validatorClient.post.composer.composeMsgWithdrawFromSubaccount(
subaccountClient.address,
subaccountClient.subaccountNumber,
assetId,
Long.fromNumber(amount * QUANTUM_MULTIPLIER),
recipient
);
resolve([msg]);
}),
false,
undefined,
undefined,
Method.BroadcastTxCommit
);
} catch (error) {
log('useSubaccount/transferFromSubaccountToAddress', error);
throw error;
}
},
resolve([msg]);
}),
false,
undefined,
undefined,
Method.BroadcastTxCommit
),
transferNativeToken: async ({
subaccountClient,
@@ -153,30 +129,24 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
subaccountClient: SubaccountClient;
amount: number;
recipient: string;
}) => {
try {
return await compositeClient?.validatorClient.post.send(
subaccountClient.wallet,
() =>
new Promise((resolve) => {
const msg = compositeClient?.sendTokenMessage(
subaccountClient.wallet,
amount.toString(),
recipient
);
}) =>
await compositeClient?.validatorClient.post.send(
subaccountClient.wallet,
() =>
new Promise((resolve) => {
const msg = compositeClient?.sendTokenMessage(
subaccountClient.wallet,
amount.toString(),
recipient,
);
resolve([msg]);
}),
false,
compositeClient?.validatorClient?.post.defaultDydxGasPrice,
undefined,
Method.BroadcastTxCommit
);
} catch (error) {
log('useSubaccount/transferNativeToken', error);
throw error;
}
},
resolve([msg]);
}),
false,
compositeClient?.validatorClient?.post.defaultDydxGasPrice,
undefined,
Method.BroadcastTxCommit
),
sendSquidWithdrawFromSubaccount: async ({
subaccountClient,
@@ -188,27 +158,20 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
payload: string;
}) => {
if (!compositeClient) throw new Error('client not initialized');
try {
const transaction = JSON.parse(payload);
const msg = compositeClient.withdrawFromSubaccountMessage(
subaccountClient,
amount.toFixed(usdcDecimals)
);
const ibcMsg: EncodeObject = {
typeUrl: transaction.msgTypeUrl,
value: transaction.msg,
};
const transaction = JSON.parse(payload);
return await compositeClient.send(
subaccountClient.wallet,
() => Promise.resolve([msg, ibcMsg]),
false
);
} catch (error) {
log('useSubaccount/sendSquidWithdrawFromSubaccount', error);
throw error;
}
const msg = compositeClient.withdrawFromSubaccountMessage(subaccountClient, amount.toString());
const ibcMsg: EncodeObject = {
typeUrl: transaction.msgTypeUrl,
value: transaction.msg,
};
return await compositeClient.send(
subaccountClient.wallet,
() => Promise.resolve([msg, ibcMsg]),
false
);
},
}),
[compositeClient]
-4
View File
@@ -19,10 +19,8 @@ export const useTokenConfigs = (): {
},
};
usdcDenom: string;
usdcDecimals: number;
usdcLabel: string;
chainTokenDenom: string;
chainTokenDecimals: number;
chainTokenLabel: string;
} => {
const { selectedNetwork } = useSelectedNetwork();
@@ -31,10 +29,8 @@ export const useTokenConfigs = (): {
return {
tokensConfigs,
usdcDenom: tokensConfigs[DydxChainAsset.USDC].denom,
usdcDecimals: tokensConfigs[DydxChainAsset.USDC].decimals,
usdcLabel: tokensConfigs[DydxChainAsset.USDC].name,
chainTokenDenom: tokensConfigs[DydxChainAsset.CHAINTOKEN].denom,
chainTokenDecimals: tokensConfigs[DydxChainAsset.CHAINTOKEN].decimals,
chainTokenLabel: tokensConfigs[DydxChainAsset.CHAINTOKEN].name,
};
};
-11
View File
@@ -1,11 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
<g clip-path="url(#clip0_18204_36775)">
<path d="M13.2426 6.25736C14.0817 7.09647 14.6531 8.16557 14.8846 9.32946C15.1162 10.4933 14.9973 11.6997 14.5432 12.7961C14.0891 13.8925 13.32 14.8295 12.3334 15.4888C11.3467 16.1481 10.1866 16.5 8.99993 16.5C7.81324 16.5 6.6532 16.1481 5.66651 15.4888C4.67981 14.8295 3.91078 13.8925 3.45665 12.7961C3.00253 11.6997 2.88371 10.4933 3.11522 9.32946C3.34673 8.16557 3.91817 7.09647 4.75729 6.25736" stroke="#C8C7D8" stroke-width="1.35" stroke-linecap="round"/>
<path d="M11.25 9L9 11.25M9 11.25L6.75 9M9 11.25V1.6875" stroke="#C8C7D8" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_18204_36775">
<rect width="18" height="18" fill="white"/>
</clipPath>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 886 B

-2
View File
@@ -19,7 +19,6 @@ export { default as CoinsIcon } from './coins.svg';
export { default as CommentIcon } from './comment.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 DepthChartIcon } from './depth-chart.svg';
export { default as DiscordIcon } from './discord.svg';
export { default as ExportKeysIcon } from './export-keys.svg';
@@ -60,7 +59,6 @@ export { default as TransferIcon } from './transfer.svg';
export { default as TriangleIcon } from './triangle.svg';
export { default as TryAgainIcon } from './try-again.svg';
export { default as WarningIcon } from './warning.svg';
export { default as WithdrawIcon } from './withdraw.svg';
// Wallets
export { default as BitkeepIcon } from './wallets/bitkeep.svg';
-4
View File
@@ -1,4 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
<path d="M13.2426 6.2573C14.0817 7.09641 14.6531 8.16551 14.8846 9.3294C15.1162 10.4933 14.9973 11.6997 14.5432 12.796C14.0891 13.8924 13.32 14.8295 12.3334 15.4888C11.3467 16.148 10.1866 16.4999 8.99993 16.4999C7.81324 16.4999 6.6532 16.148 5.66651 15.4888C4.67981 14.8295 3.91078 13.8924 3.45665 12.796C3.00253 11.6997 2.88371 10.4933 3.11522 9.3294C3.34673 8.16551 3.91817 7.09641 4.75729 6.2573" stroke="#C8C7D8" stroke-width="1.35" stroke-linecap="round"/>
<path d="M11.25 2.9375L9 0.6875M9 0.6875L6.75 2.9375M9 0.6875V10.25" stroke="#C8C7D8" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 723 B

+6 -10
View File
@@ -180,7 +180,7 @@ Styled.MobileProfileLayout = styled.div`
${layoutMixins.contentContainerPage}
gap: 1rem;
padding: 1.25rem;
padding: 1rem;
`;
Styled.Header = styled.header`
@@ -278,17 +278,13 @@ Styled.RewardsPanel = styled(Panel)`
`;
Styled.TablePanel = styled(Panel)`
--panel-content-paddingY: 0;
--panel-content-paddingX: 0;
> div > div {
margin-top: 0.5rem;
--scrollArea-height: 10rem;
border-radius: 0.875rem;
}
max-width: calc(100vw - 2rem);
max-height: 10rem;
margin-top: 0.5rem;
padding: 0;
border-radius: 0.875rem;
table {
max-height: 10rem;
--tableCell-padding: 0.25rem 1rem;
--tableRow-backgroundColor: var(--color-layer-3);
background-color: var(--color-layer-3);
@@ -131,7 +131,7 @@ export const AccountDetailsAndHistory = () => {
key: 'BuyingPower',
labelKey: STRING_KEYS.BUYING_POWER,
type: OutputType.Fiat,
value: MustBigNumber(buyingPower?.current).lt(0) ? undefined : buyingPower?.current, // show '-' when buying power is negative
value: buyingPower?.current,
},
].filter(isTruthy);
+106 -131
View File
@@ -1,12 +1,12 @@
import { useCallback, useMemo } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { Nullable } from '@dydxprotocol/v4-abacus';
import styled, { AnyStyledComponent } from 'styled-components';
import { shallowEqual, useSelector } from 'react-redux';
import { FeeTier } from '@/constants/abacus';
import { FEE_DECIMALS } from '@/constants/numbers';
import { FEE_DECIMALS, QUANTUM_MULTIPLIER } from '@/constants/numbers';
import { STRING_KEYS } from '@/constants/localization';
import { useBreakpoints, useStringGetter } from '@/hooks';
import { useAccounts, useBreakpoints, useStringGetter } from '@/hooks';
import { breakpoints } from '@/styles';
import { layoutMixins } from '@/styles/layoutMixins';
import { tableMixins } from '@/styles/tableMixins';
@@ -29,8 +29,9 @@ const EQUALITY_SYMBOL_MAP = {
};
export const Fees = () => {
const { dydxAddress } = useAccounts();
const stringGetter = useStringGetter();
const { isTablet, isNotTablet } = useBreakpoints();
const { isNotTablet } = useBreakpoints();
const userFeeTier = useSelector(getUserFeeTier, shallowEqual);
const userStats = useSelector(getUserStats, shallowEqual);
const feeTiers = useSelector(getFeeTiers, shallowEqual);
@@ -55,28 +56,28 @@ export const Fees = () => {
<Styled.AdditionalConditions>
{!isAdditional && !totalShare && !makerShare && <Output type={OutputType.Text} />}
{!!totalShare && (
<Styled.AdditionalConditionsText>
{isAdditional && stringGetter({ key: STRING_KEYS.AND })}{' '}
{stringGetter({ key: STRING_KEYS.EXCHANGE_MARKET_SHARE })}{' '}
<Styled.Highlighted>{'>'}</Styled.Highlighted>{' '}
<Styled.TextRow>
{isAdditional && <span>{stringGetter({ key: STRING_KEYS.AND })}</span>}
<span>{stringGetter({ key: STRING_KEYS.EXCHANGE_MARKET_SHARE })}</span>
<Styled.Highlighted>{'>'}</Styled.Highlighted>
<Styled.HighlightOutput
type={OutputType.Percent}
value={totalShare}
fractionDigits={0}
/>
</Styled.AdditionalConditionsText>
</Styled.TextRow>
)}
{!!makerShare && (
<Styled.AdditionalConditionsText>
{isAdditional && stringGetter({ key: STRING_KEYS.AND })}{' '}
{stringGetter({ key: STRING_KEYS.MAKER_MARKET_SHARE })}{' '}
<Styled.Highlighted>{'>'}</Styled.Highlighted>{' '}
<Styled.TextRow>
{isAdditional && <span>{stringGetter({ key: STRING_KEYS.AND })}</span>}
<span>{stringGetter({ key: STRING_KEYS.MAKER_MARKET_SHARE })}</span>
<Styled.Highlighted>{'>'}</Styled.Highlighted>
<Styled.HighlightOutput
type={OutputType.Percent}
value={makerShare}
fractionDigits={0}
/>
</Styled.AdditionalConditionsText>
</Styled.TextRow>
)}
</Styled.AdditionalConditions>
),
@@ -102,90 +103,91 @@ export const Fees = () => {
},
]}
/>
<Styled.FeeTable
label="Fee Tiers"
data={feeTiers || []}
getRowKey={(row: FeeTier) => row.tier}
getRowAttributes={(row: FeeTier) => ({
'data-yours': row.tier === userFeeTier,
})}
columns={(
[
{
columnKey: 'tier',
getCellValue: (row) => row.tier,
label: stringGetter({ key: STRING_KEYS.TIER }),
allowsSorting: false,
renderCell: ({ tier }) => (
<Styled.Tier>
<Styled.Output type={OutputType.Text} value={tier} />
{tier === userFeeTier && (
<Styled.YouTag size={TagSize.Medium}>
{stringGetter({ key: STRING_KEYS.YOU })}
</Styled.YouTag>
)}
</Styled.Tier>
),
},
{
columnKey: 'volume',
getCellValue: (row) => row.volume,
label: stringGetter({ key: STRING_KEYS.VOLUME_30D }),
allowsSorting: false,
renderCell: ({ symbol, volume, makerShare, totalShare }) => (
<>
<span>{`${
symbol in EQUALITY_SYMBOL_MAP
? EQUALITY_SYMBOL_MAP[symbol as keyof typeof EQUALITY_SYMBOL_MAP]
: symbol
} `}</span>
<Styled.HighlightOutput type={OutputType.CompactFiat} value={volume} />
{isTablet &&
AdditionalConditions({ totalShare, makerShare, isAdditional: true })}
</>
),
},
isNotTablet && {
columnKey: 'condition',
getCellValue: (row) => row.volume,
label: stringGetter({ key: STRING_KEYS.ADDITIONAL_CONDITION }),
allowsSorting: false,
renderCell: ({ totalShare, makerShare }) =>
AdditionalConditions({ totalShare, makerShare }),
},
{
columnKey: 'maker',
getCellValue: (row) => row.maker,
label: stringGetter({ key: STRING_KEYS.MAKER }),
allowsSorting: false,
renderCell: ({ maker }) => (
<Styled.HighlightOutput
type={OutputType.SmallPercent}
value={maker}
fractionDigits={FEE_DECIMALS}
/>
),
},
{
columnKey: 'taker',
getCellValue: (row) => row.taker,
label: stringGetter({ key: STRING_KEYS.TAKER }),
allowsSorting: false,
renderCell: ({ taker }) => (
<Styled.HighlightOutput
type={OutputType.SmallPercent}
value={taker}
fractionDigits={FEE_DECIMALS}
/>
),
},
] as ColumnDef<FeeTier>[]
).filter(isTruthy)}
selectionBehavior="replace"
withOuterBorder={isNotTablet}
withInnerBorders
/>
<div>
<Styled.FeeTable
label="Fee Tiers"
data={feeTiers || []}
getRowKey={(row: FeeTier) => row.tier}
getRowAttributes={(row: FeeTier) => ({
'data-yours': row.tier === userFeeTier,
})}
columns={(
[
{
columnKey: 'tier',
getCellValue: (row) => row.tier,
label: stringGetter({ key: STRING_KEYS.TIER }),
allowsSorting: false,
renderCell: ({ tier }) => (
<Styled.Tier>
<Styled.Output type={OutputType.Text} value={tier} />
{tier === userFeeTier && (
<Styled.YouTag size={TagSize.Medium}>
{stringGetter({ key: STRING_KEYS.YOU })}
</Styled.YouTag>
)}
</Styled.Tier>
),
},
{
columnKey: 'volume',
getCellValue: (row) => row.volume,
label: stringGetter({ key: STRING_KEYS.VOLUME_30D }),
allowsSorting: false,
renderCell: ({ symbol, volume, makerShare, totalShare }) => (
<>
<span>{`${
symbol in EQUALITY_SYMBOL_MAP
? EQUALITY_SYMBOL_MAP[symbol as keyof typeof EQUALITY_SYMBOL_MAP]
: symbol
} `}</span>
<Styled.HighlightOutput type={OutputType.CompactFiat} value={volume} />
{!isNotTablet &&
AdditionalConditions({ totalShare, makerShare, isAdditional: true })}
</>
),
},
isNotTablet && {
columnKey: 'condition',
getCellValue: (row) => row.volume,
label: stringGetter({ key: STRING_KEYS.ADDITIONAL_CONDITION }),
allowsSorting: false,
renderCell: ({ totalShare, makerShare }) =>
AdditionalConditions({ totalShare, makerShare }),
},
{
columnKey: 'maker',
getCellValue: (row) => row.maker,
label: stringGetter({ key: STRING_KEYS.MAKER }),
allowsSorting: false,
renderCell: ({ maker }) => (
<Styled.HighlightOutput
type={OutputType.SmallPercent}
value={maker}
fractionDigits={FEE_DECIMALS}
/>
),
},
{
columnKey: 'taker',
getCellValue: (row) => row.taker,
label: stringGetter({ key: STRING_KEYS.TAKER }),
allowsSorting: false,
renderCell: ({ taker }) => (
<Styled.HighlightOutput
type={OutputType.SmallPercent}
value={taker}
fractionDigits={FEE_DECIMALS}
/>
),
},
] as ColumnDef<FeeTier>[]
).filter(isTruthy)}
selectionBehavior="replace"
withOuterBorder={isNotTablet}
withInnerBorders
/>
</div>
</Styled.ContentWrapper>
</AttachedExpandingSection>
);
@@ -196,43 +198,21 @@ const Styled: Record<string, AnyStyledComponent> = {};
Styled.ContentWrapper = styled.div`
${layoutMixins.flexColumn}
gap: 1.5rem;
max-width: 100vw;
`;
Styled.AdditionalConditions = styled.div`
${tableMixins.cellContentColumn}
justify-content: end;
color: var(--color-text-0);
font: var(--font-small-book);
> :nth-child(2) {
font: var(--font-small-book);
}
`;
Styled.AdditionalConditionsText = styled.span`
display: flex;
gap: 0.5ch;
@media ${breakpoints.mobile} {
display: inline;
max-width: 8rem;
min-width: 0;
output {
display: inline;
}
font: var(--font-base-book);
}
`;
Styled.FeesDetails = styled(Details)`
gap: 1rem;
@media ${breakpoints.notTablet} {
margin: 0 1.25rem;
}
@media ${breakpoints.tablet} {
padding: 1rem 1rem 0 1rem;
--details-grid-numColumns: 1;
@@ -257,7 +237,11 @@ Styled.FeesDetails = styled(Details)`
}
output {
font: var(--font-base-book);
font: var(--font-medium-book);
@media ${breakpoints.tablet} {
font: var(--font-base-book);
}
}
`;
@@ -287,11 +271,6 @@ Styled.FeeTable = styled(Table)`
font: var(--font-base-book);
@media ${breakpoints.mobile} {
--tableCell-padding: 1rem 1.25rem;
font: var(--font-small-book);
}
tbody tr {
&[data-yours='true'] {
background-color: var(--color-layer-3);
@@ -304,10 +283,6 @@ Styled.FeeTable = styled(Table)`
@media ${breakpoints.notTablet} {
--tableHeader-backgroundColor: var(--color-layer-1);
thead tr {
--border-width: 0;
}
}
`;
+4 -9
View File
@@ -32,11 +32,11 @@ export const DYDXBalancePanel = () => {
const { chainTokenLabel } = useTokenConfigs();
return (
<Styled.Panel
<Panel
slotHeader={
<Styled.Header>
<Styled.Title>
<AssetIcon symbol={chainTokenLabel} />
{/* <AssetIcon symbol="DYDX" /> */}
{chainTokenLabel}
</Styled.Title>
<Styled.ReceiveAndTransferButtons>
@@ -117,19 +117,14 @@ export const DYDXBalancePanel = () => {
]}
/>
</Styled.Content>
</Styled.Panel>
</Panel>
);
};
const Styled: Record<string, AnyStyledComponent> = {};
Styled.Panel = styled(Panel)`
--panel-paddingX: 1.5rem;
`;
Styled.Header = styled.div`
${layoutMixins.spacedRow}
gap: 1rem;
padding: 1rem 1.5rem 0;
`;
@@ -182,7 +177,7 @@ Styled.WalletAndStakedBalance = styled(Details)`
--details-item-backgroundColor: var(--color-layer-6);
grid-template-columns: 1fr 1fr;
gap: 1rem;
gap: 0.5rem;
> div {
gap: 1rem;
+40 -42
View File
@@ -71,7 +71,7 @@ export const MigratePanel = () => {
</Styled.Description>
</Styled.MigratePanel>
) : (
<Styled.MigratePanel
<Styled.MobileMigratePanel
slotHeader={
<Styled.MobileMigrateHeader>
<h3>
@@ -88,52 +88,49 @@ export const MigratePanel = () => {
</Styled.MobileMigrateHeader>
}
>
<Styled.Column>
<Styled.WithReceipt
slotReceipt={
<Styled.Details
items={[
{
key: 'available-to-migrate',
label: (
<Styled.InlineRow>
{stringGetter({ key: STRING_KEYS.AVAILABLE_TO_MIGRATE })}
<Tag>DYDX</Tag>
</Styled.InlineRow>
),
value: <Output type={OutputType.Asset} value={tokenBalance} />,
},
]}
/>
}
>
{import.meta.env.VITE_TOKEN_MIGRATION_URI && (
<Button
action={tokenBalance ? ButtonAction.Primary : ButtonAction.Base}
size={ButtonSize.Medium}
slotRight={<Icon iconName={IconName.LinkOut} />}
href={import.meta.env.VITE_TOKEN_MIGRATION_URI}
>
{stringGetter({ key: STRING_KEYS.MIGRATE_NOW })}
</Button>
)}
</Styled.WithReceipt>
<Styled.InlineRow>
{stringGetter({ key: STRING_KEYS.WANT_TO_LEARN })}
<Link href={TOKEN_MIGRATION_LEARN_MORE_LINK} withIcon>
{stringGetter({ key: STRING_KEYS.CLICK_HERE })}
</Link>
</Styled.InlineRow>
</Styled.Column>
</Styled.MigratePanel>
<Styled.WithReceipt
slotReceipt={
<Styled.Details
items={[
{
key: 'available-to-migrate',
label: (
<Styled.InlineRow>
{stringGetter({ key: STRING_KEYS.AVAILABLE_TO_MIGRATE })}
<Tag>DYDX</Tag>
</Styled.InlineRow>
),
value: <Output type={OutputType.Asset} value={tokenBalance} />,
},
]}
/>
}
>
{import.meta.env.VITE_TOKEN_MIGRATION_URI && (
<Button
action={tokenBalance ? ButtonAction.Primary : ButtonAction.Base}
size={ButtonSize.Medium}
slotRight={<Icon iconName={IconName.LinkOut} />}
href={import.meta.env.VITE_TOKEN_MIGRATION_URI}
>
{stringGetter({ key: STRING_KEYS.MIGRATE_NOW })}
</Button>
)}
</Styled.WithReceipt>
<Styled.InlineRow>
{stringGetter({ key: STRING_KEYS.WANT_TO_LEARN })}
<Link href={TOKEN_MIGRATION_LEARN_MORE_LINK} withIcon>
{stringGetter({ key: STRING_KEYS.CLICK_HERE })}
</Link>
</Styled.InlineRow>
</Styled.MobileMigratePanel>
);
};
const Styled: Record<string, AnyStyledComponent> = {};
Styled.MigratePanel = styled(Panel)`
--panel-paddingX: 1.5rem;
width: 100%;
padding: 1rem 1.5rem;
`;
Styled.Title = styled.h3`
@@ -166,9 +163,10 @@ Styled.Description = styled.div`
--link-color: var(--color-text-1);
`;
Styled.Column = styled.div`
Styled.MobileMigratePanel = styled(Panel)`
${layoutMixins.flexColumn}
gap: 1rem;
align-items: center;
`;
+27 -22
View File
@@ -40,7 +40,11 @@ export const RewardsPage = () => {
<Styled.Page>
{import.meta.env.VITE_V3_TOKEN_ADDRESS && <MigratePanel />}
<Styled.PanelRow>
{isTablet && <DYDXBalancePanel />}
{isTablet && (
<Styled.BalancePanelContainer>
<DYDXBalancePanel />
</Styled.BalancePanelContainer>
)}
<Styled.Panel
slotHeader={<Styled.Title>{stringGetter({ key: STRING_KEYS.GOVERNANCE })}</Styled.Title>}
@@ -68,7 +72,11 @@ export const RewardsPage = () => {
</Styled.Description>
</Styled.Panel>
{isNotTablet && <DYDXBalancePanel />}
{isNotTablet && (
<Styled.BalancePanelContainer>
<DYDXBalancePanel />
</Styled.BalancePanelContainer>
)}
</Styled.PanelRow>
</Styled.Page>
);
@@ -79,26 +87,10 @@ const Styled: Record<string, AnyStyledComponent> = {};
Styled.Page = styled.div`
${layoutMixins.contentContainerPage}
gap: 1.5rem;
padding: 2rem;
align-items: center;
> * {
--content-max-width: 70rem;
max-width: min(calc(100vw - 4rem), var(--content-max-width));
}
@media ${breakpoints.tablet} {
padding: 1.25rem;
> * {
max-width: calc(100vw - 2.5rem);
width: 100%;
}
}
`;
Styled.Panel = styled(Panel)`
--panel-paddingX: 1.5rem;
padding: 1rem 1.5rem;
`;
Styled.Title = styled.h3`
@@ -113,14 +105,27 @@ Styled.Description = styled.div`
`;
Styled.PanelRow = styled.div`
${layoutMixins.gridEqualColumns}
${layoutMixins.spacedRow}
gap: 1.5rem;
max-width: min(100vw, var(--content-max-width));
align-items: flex-start;
> section {
cursor: pointer;
}
@media ${breakpoints.tablet} {
grid-auto-flow: row;
grid-template-columns: 1fr;
max-width: auto;
}
`;
Styled.BalancePanelContainer = styled.div`
width: 21.25rem;
@media ${breakpoints.tablet} {
width: auto;
}
`;
@@ -130,5 +135,5 @@ Styled.IconButton = styled(IconButton)`
`;
Styled.Arrow = styled.div`
padding: 1rem;
padding: 1rem 1.5rem;
`;
+2 -2
View File
@@ -227,8 +227,8 @@ export const HorizontalPanel = ({ isOpen = true, setIsOpen }: ElementProps) => {
},
]}
value={view}
onValueChange={setView}
onInteraction={() => {
onValueChange={(newView: string) => {
setView((newView || view) as PanelView);
setIsOpen?.(true);
}}
/>
@@ -151,10 +151,7 @@ export const AccountInfoConnectedState = () => {
),
label: stringGetter({ key: STRING_KEYS.BUYING_POWER }),
type: OutputType.Fiat,
value:
MustBigNumber(buyingPower?.current).lt(0) && buyingPower?.postOrder === null
? undefined
: buyingPower,
value: buyingPower,
},
].map(
({
+1 -1
View File
@@ -29,7 +29,7 @@ export const MarketFilter = ({
<>
{!isSearch && (
<ToggleGroup
items={Object.values(filters).map((value) => ({
items={Object.entries(filters).map(([key, value]) => ({
label: stringGetter({ key: MARKET_FILTER_LABELS[value] }),
value,
}))}
+2
View File
@@ -198,6 +198,8 @@ Styled.Details = styled(Details)`
@media ${breakpoints.tablet} {
${layoutMixins.withOuterAndInnerBorders}
display: grid;
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
font: var(--font-small-book);
> * {
+3 -1
View File
@@ -246,7 +246,9 @@ export const FundingChart = ({ selectedLocale }: ElementProps) => {
}[rate] || '',
}))}
value={fundingRateView}
onValueChange={setFundingRateView}
onValueChange={(newRate: FundingRateResolution) => {
if (newRate) setFundingRateView(newRate);
}}
size={ButtonSize.XSmall}
/>
</Styled.FundingRateToggle>
+3 -1
View File
@@ -73,7 +73,9 @@ export const TradeDialog = ({ isOpen, setIsOpen, slotTrigger }: ElementProps) =>
<Styled.ToggleGroup
items={allTradeTypeItems}
value={selectedTradeType}
onValueChange={onTradeTypeChange}
onValueChange={(tradeType: TradeTypes) =>
onTradeTypeChange(tradeType || selectedTradeType)
}
/>
),
},
@@ -1,5 +1,5 @@
import { type Dispatch, type SetStateAction, useState, type ReactNode } from 'react';
import styled, { type AnyStyledComponent } from 'styled-components';
import styled, { type AnyStyledComponent, } from 'styled-components';
import { shallowEqual, useSelector } from 'react-redux';
import type { RouteData } from '@0xsquid/sdk';
@@ -32,8 +32,6 @@ import { WithReceipt } from '@/components/WithReceipt';
import { getSubaccountBuyingPower, getSubaccountEquity } from '@/state/accountSelectors';
import { getTransferInputs } from '@/state/inputsSelectors';
import { MustBigNumber } from '@/lib/numbers';
import { SlippageEditor } from '../SlippageEditor';
type ElementProps = {
@@ -133,7 +131,7 @@ export const DepositButtonAndReceipt = ({
value: (
<DiffOutput
type={OutputType.Fiat}
value={MustBigNumber(buyingPower).lt(0) ? undefined : buyingPower}
value={buyingPower}
newValue={newBuyingPower}
sign={NumberSign.Positive}
withDiff={Boolean(newBuyingPower) && buyingPower !== newBuyingPower}
+1 -1
View File
@@ -209,7 +209,7 @@ export const ClosePositionForm = ({
value: value.toString(),
}))}
value={percent?.toString() ?? ''}
onValueChange={onSelectPercentage}
onValueChange={(value: any) => onSelectPercentage((value || percent?.toString()) ?? '')}
shape={ButtonShape.Rectangle}
/>
@@ -153,7 +153,9 @@ export const MarketLeverageInput = ({
value: MustBigNumber(leverageAmount).toFixed(LEVERAGE_DECIMALS),
}))}
value={MustBigNumber(formattedLeverageValue).abs().toFixed(LEVERAGE_DECIMALS)} // sign agnostic
onValueChange={updateLeverage}
onValueChange={(option?: number) =>
updateLeverage(option === undefined ? formattedLeverageValue : option)
}
shape={ButtonShape.Rectangle}
/>
</>
+25 -61
View File
@@ -36,7 +36,6 @@ import { truncateAddress } from '@/lib/wallet';
import { layoutMixins } from '@/styles/layoutMixins';
import { headerMixins } from '@/styles/headerMixins';
import { MustBigNumber } from '@/lib/numbers';
export const AccountMenu = () => {
const stringGetter = useStringGetter();
@@ -50,8 +49,6 @@ export const AccountMenu = () => {
const { evmAddress, walletType, dydxAddress, hdKey } = useAccounts();
const usdcBalance = freeCollateral?.current || 0;
const onRecoverKeys = () => {
dispatch(openDialog({ type: DialogTypes.Onboarding }));
};
@@ -125,11 +122,7 @@ export const AccountMenu = () => {
</Styled.label>
<Styled.BalanceOutput type={OutputType.Asset} value={nativeTokenBalance} />
</div>
<AssetActions
asset={DydxChainAsset.CHAINTOKEN}
dispatch={dispatch}
hasBalance={nativeTokenBalance.gt(0)}
/>
<AssetActions asset={DydxChainAsset.CHAINTOKEN} dispatch={dispatch} />
</div>
<div>
<div>
@@ -142,16 +135,11 @@ export const AccountMenu = () => {
</Styled.label>
<Styled.BalanceOutput
type={OutputType.Asset}
value={usdcBalance}
value={freeCollateral?.current || 0}
fractionDigits={2}
/>
</div>
<AssetActions
asset={DydxChainAsset.USDC}
dispatch={dispatch}
hasBalance={MustBigNumber(usdcBalance).gt(0)}
withOnboarding
/>
<AssetActions asset={DydxChainAsset.USDC} dispatch={dispatch} />
</div>
</Styled.Balances>
</Styled.AccountInfo>
@@ -224,48 +212,28 @@ export const AccountMenu = () => {
);
};
const AssetActions = memo(
({
asset,
dispatch,
withOnboarding,
hasBalance,
}: {
asset: DydxChainAsset;
dispatch: Dispatch;
withOnboarding?: boolean;
hasBalance?: boolean;
}) => (
<Styled.InlineRow>
{[
withOnboarding &&
hasBalance && {
dialogType: DialogTypes.Withdraw,
iconName: IconName.Withdraw,
},
withOnboarding && {
dialogType: DialogTypes.Deposit,
iconName: IconName.Deposit,
},
hasBalance && {
dialogType: DialogTypes.Transfer,
dialogProps: { selectedAsset: asset },
iconName: IconName.Send,
},
]
.filter(isTruthy)
.map(({ iconName, dialogType, dialogProps }) => (
<Styled.IconButton
key={dialogType}
action={ButtonAction.Base}
shape={ButtonShape.Square}
iconName={iconName}
onClick={() => dispatch(openDialog({ type: dialogType, dialogProps }))}
/>
))}
</Styled.InlineRow>
)
);
const AssetActions = memo(({ asset, dispatch }: { asset: DydxChainAsset; dispatch: Dispatch }) => (
<Styled.InlineRow>
{[
// TODO(@rosepuppy): Add withdraw action for USDC
{
dialogType: DialogTypes.Receive,
iconName: IconName.Qr,
},
{ dialogType: DialogTypes.Transfer, iconName: IconName.Send },
].map(({ iconName, dialogType }) => (
<IconButton
key={dialogType}
action={ButtonAction.Base}
shape={ButtonShape.Square}
iconName={iconName}
onClick={() =>
dispatch(openDialog({ type: dialogType, dialogProps: { selectedAsset: asset } }))
}
/>
))}
</Styled.InlineRow>
));
const Styled: Record<string, AnyStyledComponent> = {};
@@ -383,7 +351,3 @@ Styled.ConnectToChain = styled(Styled.Column)`
font: var(--font-small-book);
}
`;
Styled.IconButton = styled(IconButton)`
--button-padding: 0 0.25rem;
`;
+5 -6
View File
@@ -1,13 +1,10 @@
import React, { useMemo } from 'react';
import styled from 'styled-components';
import { layoutMixins } from '@/styles/layoutMixins';
import { groupBy } from 'lodash';
import { type Notification, NotificationStatus } from '@/constants/notifications';
import { useBreakpoints } from '@/hooks';
import { useNotifications } from '@/hooks/useNotifications';
import { CloseIcon } from '@/icons';
import { Button } from '@/components/Button';
import { ButtonAction, ButtonSize } from '@/constants/buttons';
@@ -16,6 +13,10 @@ import { DialogPlacement } from '@/components/Dialog';
import { Output, OutputType } from '@/components/Output';
import { IconButton } from '@/components/IconButton';
import { Toolbar } from '@/components/Toolbar';
import { CloseIcon } from '@/icons';
import styled from 'styled-components';
import { layoutMixins } from '@/styles/layoutMixins';
type ElementProps = {
slotTrigger?: React.ReactNode;
@@ -26,7 +27,6 @@ export const NotificationsMenu = ({
slotTrigger,
placement = DialogPlacement.Sidebar,
}: ElementProps) => {
const { isTablet } = useBreakpoints();
const {
notifications,
getDisplayData,
@@ -173,7 +173,6 @@ export const NotificationsMenu = ({
</$FooterToolbar>
}
placement={placement}
preventClose={isTablet}
/>
);
};