JUP Asset details (#285)

*  add JUP assets

* localize eg
This commit is contained in:
Jared Vu 2024-02-07 09:49:46 -08:00 committed by GitHub
parent 3b75e60bd2
commit 597456a0d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 141 additions and 106 deletions

View File

@ -41,7 +41,7 @@
"@cosmjs/tendermint-rpc": "^0.32.1",
"@dydxprotocol/v4-abacus": "^1.4.2",
"@dydxprotocol/v4-client-js": "^1.0.20",
"@dydxprotocol/v4-localization": "^1.1.24",
"@dydxprotocol/v4-localization": "^1.1.25",
"@ethersproject/providers": "^5.7.2",
"@js-joda/core": "^5.5.3",
"@radix-ui/react-accordion": "^1.1.2",

16
pnpm-lock.yaml generated
View File

@ -1,5 +1,9 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
follow-redirects: 1.15.3
@ -32,8 +36,8 @@ dependencies:
specifier: ^1.0.20
version: 1.0.20
'@dydxprotocol/v4-localization':
specifier: ^1.1.24
version: 1.1.24
specifier: ^1.1.25
version: 1.1.25
'@ethersproject/providers':
specifier: ^5.7.2
version: 5.7.2
@ -1121,8 +1125,8 @@ packages:
- utf-8-validate
dev: false
/@dydxprotocol/v4-localization@1.1.24:
resolution: {integrity: sha512-75XpxxYTpy8eIFcJINyLlvw5J93t0TrS5LacE6J5Raz9LOUWRK4VyRbdLCU2QX8AG7xiTZk1ma8ytylVZOVx3A==}
/@dydxprotocol/v4-localization@1.1.25:
resolution: {integrity: sha512-84BJMybnZBrRnDpnHlMUcOYT1r0ODtgcdgrjdzTw8b0sViTY6ne9ob690fcn/vQO+6sEdDsdt+08ud0H+ZvyYg==}
dev: false
/@dydxprotocol/v4-proto@4.0.0-dev.0:
@ -14912,7 +14916,3 @@ packages:
/zwitch@2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

View File

@ -93,6 +93,7 @@
"documentation": "https://docs.dydx.exchange/",
"community": "https://discord.com/invite/dydx",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -175,6 +176,7 @@
"documentation": "https://docs.dydx.exchange/",
"community": "https://discord.com/invite/dydx",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -258,6 +260,7 @@
"documentation": "https://docs.dydx.exchange/",
"community": "https://discord.com/invite/dydx",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -340,6 +343,7 @@
"documentation": "https://docs.dydx.exchange/",
"community": "https://discord.com/invite/dydx",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -424,6 +428,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -503,7 +508,8 @@
"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"
"blogs": "https://www.dydx.foundation/blog",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals"
},
"wallets": {
"walletconnect": {
@ -591,6 +597,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -679,6 +686,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -764,6 +772,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -849,6 +858,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -934,6 +944,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -1019,6 +1030,7 @@
"reduceOnlyLearnMore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnMore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnMore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnMore": "https://help.dydx.exchange/en/articles/8565867-secret-phrase-on-dydx-chain",
@ -1099,7 +1111,8 @@
"documentation": "https://docs.dydx.exchange/",
"community": "https://discord.com/invite/dydx",
"feedback": "https://docs.google.com/forms/d/e/1FAIpQLSezLsWCKvAYDEb7L-2O4wOON1T56xxro9A2Azvl6IxXHP_15Q/viewform",
"blogs": "https://www.dydx.foundation/blog"
"blogs": "https://www.dydx.foundation/blog",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals"
},
"wallets": {
"walletconnect": {
@ -1181,6 +1194,7 @@
"reduceOnlyLearnmore": "https://help.dydx.exchange/articles/6345793-reduce-only-orders",
"mintscanBase": "https://testnet.mintscan.io/dydx-testnet",
"governanceLearnmore": "https://help.dydx.exchange",
"newMarketProposalLearnMore": "https://dydx.exchange/blog/new-market-proposals",
"stakingLearnmore": "https://help.dydx.exchange",
"keplrDashboard": "https://testnet.keplr.app/",
"accountExportLearnmore": "https://help.dydx.exchange",
@ -1266,6 +1280,7 @@
"community": "[HTTP link to community, can be null]",
"help": "[HTTP link to help page, can be null]",
"governanceLearnMore": "[HTTP link to governance learn more, can be null]",
"newMarketProposalLearnMore": "[HTTP link to new market proposal learn more, can be null]",
"stakingLearnMore": "[HTTP link to staking learn more, can be null]",
"keplrDashboard": "[HTTP link to keplr dashboard, can be null]",
"accountExportLearnMore": "[HTTP link to account export learn more, can be null]",

View File

@ -176,6 +176,13 @@
"whitepaperLink": "https://dfinity.org/whitepaper.pdf",
"coinMarketCapsLink": "https://coinmarketcap.com/currencies/internet-computer/"
},
"JUP-USD": {
"name": "Jupiter",
"tags": ["Defi"],
"websiteLink": "https://station.jup.ag/",
"whitepaperLink": "https://station.jup.ag/blog/green-paper",
"coinMarketCapsLink": "https://coinmarketcap.com/currencies/jupiter-ag/"
},
"LDO-USD": {
"name": "Lido DAO",
"tags": ["Defi"],

BIN
public/currencies/jup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -31,6 +31,7 @@ const assetIcons = {
ETH: '/currencies/eth.png',
FIL: '/currencies/fil.png',
ICP: '/currencies/icp.png',
JUP: '/currencies/jup.png',
LDO: '/currencies/ldo.png',
LINK: '/currencies/link.png',
LTC: '/currencies/ltc.png',

View File

@ -1,42 +1,9 @@
export type ExchangeConfigParsedCsv = Array<{
base_asset: string;
exchange: string;
pair: string;
adjust_by_market: string;
min_2_depth: string;
avg_30d_vol: string;
reference_price: string;
risk_assessment: string;
num_oracles: string;
liquidity_tier: string;
asset_name: string;
}>;
export type ExchangeConfigItem = {
exchangeName: string;
ticker: string;
adjustByMarket?: string;
};
export type PotentialMarketParsedCsv = Array<{
base_asset: string;
reference_price: string;
num_oracles: string;
liquidity_tier: string;
asset_name: string;
p: string;
atomic_resolution: string;
min_exchanges: string;
min_price_change_ppm: string;
price_exponent: string;
step_base_quantum: string;
ticksize_exponent: string;
subticks_per_tick: string;
min_order_size: string;
quantum_conversion_exponent: string;
}>;
export type PotentialMarketItem = {
baseAsset: string;
referencePrice: string;
@ -56,30 +23,3 @@ export type PotentialMarketItem = {
};
export const NUM_ORACLES_TO_QUALIFY_AS_SAFE = 6;
export const LIQUIDITY_TIERS = {
0: {
label: 'Large-cap',
initialMarginFraction: 0.05,
maintenanceMarginFraction: 0.03,
impactNotional: 10_000,
},
1: {
label: 'Mid-cap',
initialMarginFraction: 0.1,
maintenanceMarginFraction: 0.05,
impactNotional: 5_000,
},
2: {
label: 'Long-tail',
initialMarginFraction: 0.2,
maintenanceMarginFraction: 0.1,
impactNotional: 2_500,
},
3: {
label: 'Safety',
initialMarginFraction: 1,
maintenanceMarginFraction: 0.2,
impactNotional: 2_500,
},
};

View File

@ -1,18 +1,42 @@
import { createContext, useContext, useEffect, useState } from 'react';
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import type {
ExchangeConfigItem,
ExchangeConfigParsedCsv,
PotentialMarketItem,
PotentialMarketParsedCsv,
} from '@/constants/potentialMarkets';
import { STRING_KEYS } from '@/constants/localization';
import type { ExchangeConfigItem, PotentialMarketItem } from '@/constants/potentialMarkets';
import { log } from '@/lib/telemetry';
import { useStringGetter } from './useStringGetter';
const PotentialMarketsContext = createContext<ReturnType<typeof usePotentialMarketsContext>>({
potentialMarkets: undefined,
exchangeConfigs: undefined,
hasPotentialMarketsData: false,
liquidityTiers: {
0: {
label: 'Large-cap',
initialMarginFraction: 0.05,
maintenanceMarginFraction: 0.03,
impactNotional: 10_000,
},
1: {
label: 'Mid-cap',
initialMarginFraction: 0.1,
maintenanceMarginFraction: 0.05,
impactNotional: 5_000,
},
2: {
label: 'Long-tail',
initialMarginFraction: 0.2,
maintenanceMarginFraction: 0.1,
impactNotional: 2_500,
},
3: {
label: 'Safety',
initialMarginFraction: 1,
maintenanceMarginFraction: 0.2,
impactNotional: 2_500,
},
},
});
PotentialMarketsContext.displayName = 'PotentialMarkets';
@ -27,6 +51,7 @@ const EXCHANGE_CONFIG_FILE_PATH = '/configs/potentialMarketExchangeConfig.json';
const POTENTIAL_MARKETS_FILE_PATH = '/configs/potentialMarketParameters.json';
export const usePotentialMarketsContext = () => {
const stringGetter = useStringGetter();
const [potentialMarkets, setPotentialMarkets] = useState<PotentialMarketItem[]>();
const [exchangeConfigs, setExchangeConfigs] = useState<Record<string, ExchangeConfigItem[]>>();
@ -54,9 +79,40 @@ export const usePotentialMarketsContext = () => {
}
}, []);
const liquidityTiers = useMemo(
() => ({
0: {
label: stringGetter({ key: STRING_KEYS.LARGE_CAP }),
initialMarginFraction: 0.05,
maintenanceMarginFraction: 0.03,
impactNotional: 10_000,
},
1: {
label: 'Mid-cap',
initialMarginFraction: 0.1,
maintenanceMarginFraction: 0.05,
impactNotional: 5_000,
},
2: {
label: stringGetter({ key: STRING_KEYS.LONG_TAIL }),
initialMarginFraction: 0.2,
maintenanceMarginFraction: 0.1,
impactNotional: 2_500,
},
3: {
label: stringGetter({ key: STRING_KEYS.SAFETY }),
initialMarginFraction: 1,
maintenanceMarginFraction: 0.2,
impactNotional: 2_500,
},
}),
[stringGetter]
);
return {
potentialMarkets,
exchangeConfigs,
hasPotentialMarketsData: Boolean(potentialMarkets && exchangeConfigs),
liquidityTiers,
};
};

View File

@ -5,23 +5,24 @@ import { useSelectedNetwork } from '@/hooks';
const FALLBACK_URL = 'https://help.dydx.exchange/';
export interface LinksConfigs {
tos: string,
privacy: string,
mintscan: string,
mintscanBase: string,
feedback?: string,
help?: string,
blogs?: string,
foundation?: string,
initialMarginFractionLearnMore?: string,
reduceOnlyLearnMore?: string,
documentation?: string,
community?: string,
governanceLearnMore?: string,
stakingLearnMore?: string,
keplrDashboard?: string,
accountExportLearnMore?: string,
walletLearnMore?: string
tos: string;
privacy: string;
mintscan: string;
mintscanBase: string;
feedback?: string;
help?: string;
blogs?: string;
foundation?: string;
initialMarginFractionLearnMore?: string;
reduceOnlyLearnMore?: string;
documentation?: string;
community?: string;
governanceLearnMore?: string;
newMarketProposalLearnMore: string;
stakingLearnMore?: string;
keplrDashboard?: string;
accountExportLearnMore?: string;
walletLearnMore?: string;
}
export const useURLConfigs = (): LinksConfigs => {
@ -42,6 +43,7 @@ export const useURLConfigs = (): LinksConfigs => {
documentation: linksConfigs.documentation || FALLBACK_URL,
community: linksConfigs.community || FALLBACK_URL,
governanceLearnMore: linksConfigs.governanceLearnMore || FALLBACK_URL,
newMarketProposalLearnMore: linksConfigs.newMarketProposalLearnMore || FALLBACK_URL,
stakingLearnMore: linksConfigs.stakingLearnMore || FALLBACK_URL,
keplrDashboard: linksConfigs.keplrDashboard || FALLBACK_URL,
accountExportLearnMore: linksConfigs.accountExportLearnMore || FALLBACK_URL,

View File

@ -11,7 +11,7 @@ import { DialogTypes } from '@/constants/dialogs';
import { STRING_KEYS } from '@/constants/localization';
import { isMainnet } from '@/constants/networks';
import { NumberSign, TOKEN_DECIMALS } from '@/constants/numbers';
import { LIQUIDITY_TIERS, type PotentialMarketItem } from '@/constants/potentialMarkets';
import type { PotentialMarketItem } from '@/constants/potentialMarkets';
import {
useAccountBalance,
@ -19,6 +19,7 @@ import {
useStringGetter,
useSubaccount,
useTokenConfigs,
useURLConfigs,
} from '@/hooks';
import { usePotentialMarkets } from '@/hooks/usePotentialMarkets';
@ -31,6 +32,7 @@ import { DiffOutput } from '@/components/DiffOutput';
import { FormInput } from '@/components/FormInput';
import { Icon, IconName } from '@/components/Icon';
import { InputType } from '@/components/Input';
import { Link } from '@/components/Link';
import { Output, OutputType } from '@/components/Output';
import { Tag } from '@/components/Tag';
import { WithDetailsReceipt } from '@/components/WithDetailsReceipt';
@ -62,9 +64,10 @@ export const NewMarketPreviewStep = ({
const stringGetter = useStringGetter();
const { chainTokenDecimals, chainTokenLabel } = useTokenConfigs();
const [errorMessage, setErrorMessage] = useState();
const { exchangeConfigs } = usePotentialMarkets();
const { exchangeConfigs, liquidityTiers } = usePotentialMarkets();
const { submitNewMarketProposal } = useSubaccount();
const { newMarketProposal } = useGovernanceVariables();
const { newMarketProposalLearnMore } = useURLConfigs();
const initialDepositAmountBN = MustBigNumber(newMarketProposal.initialDepositAmount).div(
Number(`1e${chainTokenDecimals}`)
);
@ -73,7 +76,7 @@ export const NewMarketPreviewStep = ({
const [hasAcceptedTerms, setHasAcceptedTerms] = useState(false);
const { label, initialMarginFraction, maintenanceMarginFraction, impactNotional } =
LIQUIDITY_TIERS[liquidityTier as unknown as keyof typeof LIQUIDITY_TIERS];
liquidityTiers[liquidityTier as unknown as keyof typeof liquidityTiers];
const ticker = `${assetData.baseAsset}-USD`;
@ -311,10 +314,15 @@ export const NewMarketPreviewStep = ({
</Styled.ButtonRow>
<Styled.Disclaimer>
{stringGetter({
key: STRING_KEYS.PROPOSAL_DISCLAIMER,
key: STRING_KEYS.PROPOSAL_DISCLAIMER_1,
params: {
NUM_TOKENS_REQUIRED: initialDepositAmount,
NATIVE_TOKEN_DENOM: chainTokenLabel,
HERE: (
<Styled.Link href={newMarketProposalLearnMore}>
{stringGetter({ key: STRING_KEYS.HERE })}
</Styled.Link>
),
},
})}
</Styled.Disclaimer>
@ -394,3 +402,8 @@ Styled.ButtonRow = styled.div`
Styled.Button = styled(Button)`
--button-padding: 0;
`;
Styled.Link = styled(Link)`
--link-color: var(--color-accent);
display: inline;
`;

View File

@ -12,7 +12,6 @@ import { isMainnet } from '@/constants/networks';
import { TOKEN_DECIMALS } from '@/constants/numbers';
import {
LIQUIDITY_TIERS,
NUM_ORACLES_TO_QUALIFY_AS_SAFE,
type PotentialMarketItem,
} from '@/constants/potentialMarkets';
@ -74,7 +73,7 @@ export const NewMarketSelectionStep = ({
const { isMobile } = useBreakpoints();
const marketIds = useSelector(getMarketIds, shallowEqual);
const { chainTokenDecimals, chainTokenLabel } = useTokenConfigs();
const { potentialMarkets, exchangeConfigs } = usePotentialMarkets();
const { potentialMarkets, exchangeConfigs, liquidityTiers } = usePotentialMarkets();
const stringGetter = useStringGetter();
const { newMarketProposal } = useGovernanceVariables();
const initialDepositAmountBN = MustBigNumber(newMarketProposal.initialDepositAmount).div(
@ -166,7 +165,7 @@ export const NewMarketSelectionStep = ({
{assetToAdd?.assetName ?? assetToAdd.baseAsset} <Tag>{assetToAdd?.baseAsset}-USD</Tag>
</Styled.SelectedAsset>
) : (
'e.g. "BTC-USD"'
`${stringGetter({ key: STRING_KEYS.EG })} "BTC-USD"`
)}
</SearchSelectMenu>
{assetToAdd && (
@ -210,9 +209,9 @@ export const NewMarketSelectionStep = ({
</Styled.ButtonRow>
</Styled.Header>
{Object.keys(LIQUIDITY_TIERS).map((tier) => {
{Object.keys(liquidityTiers).map((tier) => {
const { maintenanceMarginFraction, impactNotional, label, initialMarginFraction } =
LIQUIDITY_TIERS[tier as unknown as keyof typeof LIQUIDITY_TIERS];
liquidityTiers[tier as unknown as keyof typeof liquidityTiers];
return (
<Styled.LiquidityTierRadioButton
key={tier}
@ -234,7 +233,7 @@ export const NewMarketSelectionStep = ({
items={[
{
key: 'imf',
label: 'IMF',
label: stringGetter({ key: STRING_KEYS.INITIAL_MARGIN_FRACTION_SHORT }),
tooltip: 'initial-margin-fraction',
value: (
<Output
@ -246,7 +245,9 @@ export const NewMarketSelectionStep = ({
},
{
key: 'mmf',
label: 'MMF',
label: stringGetter({
key: STRING_KEYS.MAINTENANCE_MARGIN_FRACTION_SHORT,
}),
tooltip: 'maintenance-margin-fraction',
value: (
<Output