diff --git a/constants/currency.ts b/constants/currency.ts index de823504a2..1260234934 100644 --- a/constants/currency.ts +++ b/constants/currency.ts @@ -77,7 +77,7 @@ export const COMMODITY_SYNTHS = new Set(['X export const sUSD_EXCHANGE_RATE = new Wei(1); export const SYNTH_DECIMALS = 18; -export const ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; +export const ETH_ADDRESS = '0x4200000000000000000000000000000000000006'; export const ATOMIC_EXCHANGES_L1 = [ 'sBTC', diff --git a/hooks/useExchange.ts b/hooks/useExchange.ts index 6abbde0bcf..1147d79e2d 100644 --- a/hooks/useExchange.ts +++ b/hooks/useExchange.ts @@ -309,7 +309,7 @@ const useExchange = ({ // TODO: Fix coingecko prices (optimism issue maybe?) const quotePriceRate = useMemo( () => - txProvider !== 'synthetix' && !isQuoteCurrencyETH && !quoteCurrency + txProvider !== 'synthetix' && !quoteCurrency ? coinGeckoPrices != null && quoteCurrencyTokenAddress != null && selectPriceCurrencyRate != null && @@ -324,7 +324,6 @@ const useExchange = ({ ), [ txProvider, - isQuoteCurrencyETH, quoteCurrency, coinGeckoPrices, quoteCurrencyTokenAddress, @@ -336,7 +335,7 @@ const useExchange = ({ ); const basePriceRate = useMemo(() => { - return txProvider !== 'synthetix' && !isBaseCurrencyETH && !baseCurrency + return txProvider !== 'synthetix' && !baseCurrency ? coinGeckoPrices != null && baseCurrencyTokenAddress != null && selectPriceCurrencyRate != null && @@ -352,7 +351,6 @@ const useExchange = ({ ); }, [ txProvider, - isBaseCurrencyETH, baseCurrency, coinGeckoPrices, baseCurrencyTokenAddress, @@ -1114,7 +1112,7 @@ const useExchange = ({ const onQuoteBalanceClick = useCallback(async () => { if (quoteCurrencyBalance != null) { if ((quoteCurrencyKey as string) === 'ETH') { - const ETH_TX_BUFFER = 0.1; + const ETH_TX_BUFFER = 0.006; const balanceWithBuffer = quoteCurrencyBalance.sub(wei(ETH_TX_BUFFER)); setQuoteCurrencyAmount( balanceWithBuffer.lt(0) diff --git a/next.config.js b/next.config.js index 675a6d4615..05f46619b8 100644 --- a/next.config.js +++ b/next.config.js @@ -80,5 +80,24 @@ module.exports = withPlugins([ styledComponents: true, }, experimental: { images: { unoptimized: true } }, + async redirects() { + return [ + { + source: '/dashboard/overview', + destination: '/dashboard', + permanent: true, + }, + { + source: '/market/:key', + destination: '/market/?asset=:key', + permanent: true, + }, + { + source: '/exchange/:base-:quote', + destination: '/exchange/?quote=:quote&base=:base', + permanent: true, + }, + ]; + }, }, ]); diff --git a/package-lock.json b/package-lock.json index 8131448318..c4d01adf37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kwenta", - "version": "3.0.3", + "version": "3.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "kwenta", - "version": "3.0.3", + "version": "3.1.0", "hasInstallScript": true, "dependencies": { "@artsy/fresnel": "1.7.0", diff --git a/package.json b/package.json index 4261722e92..bf509fc5a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kwenta", - "version": "3.0.3", + "version": "3.1.0", "scripts": { "dev": "next", "build": "next build", diff --git a/pages/exchange.tsx b/pages/exchange.tsx index b31a6eedf3..26029b9915 100644 --- a/pages/exchange.tsx +++ b/pages/exchange.tsx @@ -28,7 +28,7 @@ const Exchange: ExchangeComponent = () => { - {baseCurrencyKey != null && quoteCurrencyKey != null + {!!baseCurrencyKey && !!quoteCurrencyKey && inverseRate.gt(0) ? t('exchange.page-title-currency-pair', { baseCurrencyKey, quoteCurrencyKey, diff --git a/pages/leaderboard/index.tsx b/pages/leaderboard/index.tsx index dfcd23033a..ad743412da 100644 --- a/pages/leaderboard/index.tsx +++ b/pages/leaderboard/index.tsx @@ -28,7 +28,7 @@ const Leader: LeaderComponent = () => { </MobileHiddenView> <MobileOnlyView> <MobileMainContent> - <Leaderboard /> + <Leaderboard mobile /> </MobileMainContent> </MobileOnlyView> </PageContent> diff --git a/queries/rates/useExchangeRatesQuery.ts b/queries/rates/useExchangeRatesQuery.ts index 41105fbbe0..f0977ff75a 100644 --- a/queries/rates/useExchangeRatesQuery.ts +++ b/queries/rates/useExchangeRatesQuery.ts @@ -47,7 +47,12 @@ const useExchangeRatesQuery = (options?: UseQueryOptions<Rates>) => { const marketAsset = MarketAssetByKey[currencyKey as FuturesMarketKey]; const rate = Number(ethers.utils.formatEther(rates[idx])); - exchangeRates[marketAsset ?? currencyKey] = wei(rate); + + // add rates for each synth + exchangeRates[currencyKey] = wei(rate); + + // if a futures market exists, add the market asset rate + if (marketAsset) exchangeRates[marketAsset] = wei(rate); }); setRates(exchangeRates); diff --git a/sections/futures/Trade/MarketActions.tsx b/sections/futures/Trade/MarketActions.tsx index d24ed8bf8e..3e5ebe9141 100644 --- a/sections/futures/Trade/MarketActions.tsx +++ b/sections/futures/Trade/MarketActions.tsx @@ -7,6 +7,7 @@ import styled from 'styled-components'; import Button from 'components/Button'; import { Synths } from 'constants/currency'; import { futuresAccountState, marketInfoState, positionState } from 'store/futures'; +import { isL2State } from 'store/wallet'; import { zeroBN } from 'utils/formatters/number'; import DepositMarginModal from './DepositMarginModal'; @@ -17,6 +18,7 @@ const MarketActions: React.FC = () => { const { selectedFuturesAddress } = useRecoilValue(futuresAccountState); const position = useRecoilValue(positionState); const marketInfo = useRecoilValue(marketInfoState); + const isL2 = useRecoilValue(isL2State); const [openModal, setOpenModal] = React.useState<'deposit' | 'withdraw' | null>(null); const { useSynthsBalancesQuery } = useSynthetixQueries(); @@ -28,7 +30,7 @@ const MarketActions: React.FC = () => { <MarketActionsContainer> <MarketActionButton data-testid="futures-market-trade-button-deposit" - disabled={marketInfo?.isSuspended} + disabled={marketInfo?.isSuspended || !isL2 || !selectedFuturesAddress} onClick={() => setOpenModal('deposit')} noOutline > @@ -36,7 +38,12 @@ const MarketActions: React.FC = () => { </MarketActionButton> <MarketActionButton data-testid="futures-market-trade-button-withdraw" - disabled={position?.remainingMargin?.lte(zeroBN) || marketInfo?.isSuspended} + disabled={ + position?.remainingMargin?.lte(zeroBN) || + marketInfo?.isSuspended || + !isL2 || + !selectedFuturesAddress + } onClick={() => setOpenModal('withdraw')} noOutline > diff --git a/sections/leaderboard/AllTime/AllTime.tsx b/sections/leaderboard/AllTime/AllTime.tsx index 1d98b69ffe..61ebc0abb5 100644 --- a/sections/leaderboard/AllTime/AllTime.tsx +++ b/sections/leaderboard/AllTime/AllTime.tsx @@ -47,11 +47,9 @@ const AllTime: FC<AllTimeProps> = ({ stats, isLoading, searchTerm, onClickTrader const statsData = stats .sort((a: AccountStat, b: AccountStat) => a.rank - b.rank) .map((trader: any, i: number) => { - const pinText = trader.account === walletAddress ? PIN : ''; - return { ...trader, - rankText: `${trader.rank}${pinText}`, + rankText: trader.rank.toString(), }; }) .filter((i: { account: string; traderEns: string }) => @@ -61,14 +59,14 @@ const AllTime: FC<AllTimeProps> = ({ stats, isLoading, searchTerm, onClickTrader : true ); - return [ - ...statsData.filter( - (trader) => trader.account.toLowerCase() === walletAddress?.toLowerCase() - ), - ...statsData.filter( - (trader) => trader.account.toLowerCase() !== walletAddress?.toLowerCase() - ), - ]; + const pinRow = statsData + .filter((trader) => trader.account.toLowerCase() === walletAddress?.toLowerCase()) + .map((trader) => ({ + ...trader, + rankText: `${trader.rank}${PIN}`, + })); + + return [...pinRow, ...statsData]; }, [stats, searchTerm, walletAddress]); return ( diff --git a/sections/leaderboard/Competition/Competition.tsx b/sections/leaderboard/Competition/Competition.tsx index 0edd1628b4..65250f0fda 100644 --- a/sections/leaderboard/Competition/Competition.tsx +++ b/sections/leaderboard/Competition/Competition.tsx @@ -50,21 +50,16 @@ const Competition: FC<CompetitionProps> = ({ const cleanCompetitionData: AccountStat[] = competitionData .sort((a: AccountStat, b: AccountStat) => a.rank - b.rank) .map((trader: any, i: number) => { - const pinText = trader.account === walletAddress ? PIN : ''; - return { - account: trader.account, + ...trader, trader: trader.account, traderEns: ensInfo[trader.account], - tier: trader.tier, - rank: trader.rank, - rankText: `${trader.rank}${pinText}`, + rankText: trader.rank.toString(), traderShort: truncateAddress(trader.account), pnl: wei(trader.pnl), pnlPct: `(${formatPercent(trader?.pnl_pct)})`, totalVolume: trader.volume, totalTrades: trader.trades, - liquidations: trader.liquidations, }; }) .filter((trader: { tier: string }) => { @@ -77,14 +72,14 @@ const Competition: FC<CompetitionProps> = ({ : true ); - return [ - ...cleanCompetitionData.filter( - (trader) => trader.account.toLowerCase() === walletAddress?.toLowerCase() - ), - ...cleanCompetitionData.filter( - (trader) => trader.account.toLowerCase() !== walletAddress?.toLowerCase() - ), - ]; + const pinRow = cleanCompetitionData + .filter((trader) => trader.account.toLowerCase() === walletAddress?.toLowerCase()) + .map((trader) => ({ + ...trader, + rankText: `${trader.rank}${PIN}`, + })); + + return [...pinRow, ...cleanCompetitionData]; }, [competitionQuery, ensInfo, searchTerm, activeTier, walletAddress, walletTier, compact]); const noResultsMessage = @@ -218,8 +213,10 @@ const Competition: FC<CompetitionProps> = ({ Header: () => <TableHeader>{t('leaderboard.leaderboard.table.trader')}</TableHeader>, accessor: 'trader', Cell: (cellProps: CellProps<any>) => ( - <StyledOrderType> - <StyledValue>{cellProps.row.original.traderShort}</StyledValue> + <StyledOrderType onClick={() => onClickTrader(cellProps.row.original.account)}> + <StyledValue> + {cellProps.row.original.traderEns ?? cellProps.row.original.traderShort} + </StyledValue> {getMedal(cellProps.row.original.rank)} </StyledOrderType> ), diff --git a/sections/leaderboard/Leaderboard/Leaderboard.tsx b/sections/leaderboard/Leaderboard/Leaderboard.tsx index 4f35dc9c1b..0267c27261 100644 --- a/sections/leaderboard/Leaderboard/Leaderboard.tsx +++ b/sections/leaderboard/Leaderboard/Leaderboard.tsx @@ -21,9 +21,10 @@ import TraderHistory from '../TraderHistory'; type LeaderboardProps = { compact?: boolean; + mobile?: boolean; }; -const Leaderboard: FC<LeaderboardProps> = ({ compact }: LeaderboardProps) => { +const Leaderboard: FC<LeaderboardProps> = ({ compact, mobile }: LeaderboardProps) => { const [searchTerm, setSearchTerm] = useState(''); const [activeTier, setActiveTier] = useState<Tier>('bronze'); const [selectedTrader, setSelectedTrader] = useState(''); @@ -93,8 +94,8 @@ const Leaderboard: FC<LeaderboardProps> = ({ compact }: LeaderboardProps) => { <> <CompetitionBanner compact={true} hideBanner={compact} /> <LeaderboardContainer> - <SearchContainer compact={compact}> - <TabButtonContainer> + <SearchContainer compact={compact} mobile={mobile}> + <TabButtonContainer mobile={mobile}> {COMPETITION_TIERS.map((tier) => ( <StyledTabButton key={tier} @@ -163,19 +164,20 @@ const StyledTabButton = styled(TabButton)` margin-right: 5px; `; -const TabButtonContainer = styled.div` +const TabButtonContainer = styled.div<{ mobile: boolean | undefined }>` display: grid; grid-template-columns: repeat(4, 1fr); + margin-bottom: ${({ mobile }) => (mobile ? '16px' : '0px')}; `; -const SearchContainer = styled.div<{ compact: boolean | undefined }>` +const SearchContainer = styled.div<{ compact: boolean | undefined; mobile: boolean | undefined }>` display: ${({ compact }) => (compact ? 'none' : 'flex')}; - margin-top: ${({ compact }) => (compact ? '0' : '16px')}; - height: 35px; + flex-direction: ${({ mobile }) => (mobile ? 'column' : 'row')}; + margin-top: ${({ compact }) => (compact ? '0px' : '16px')}; + height: ${({ mobile }) => (mobile ? '85px' : '35px')}; `; const TableContainer = styled.div<{ compact: boolean | undefined }>` - margin-top: ${({ compact }) => (compact ? '0' : '6px')}; margin-bottom: ${({ compact }) => (compact ? '0' : '40px')}; `; diff --git a/translations/en.json b/translations/en.json index 6e8d1436fa..a8e61b0ba9 100644 --- a/translations/en.json +++ b/translations/en.json @@ -286,7 +286,7 @@ "from": "from", "into": "into" }, - "synth-exchange": "Synth Exchange", + "synth-exchange": "Spot Exchange", "currency-card": { "synth-name": "-", "amount-placeholder": "0.0000",