Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
platschi authored Aug 18, 2022
2 parents 43bdedb + c57996c commit 0daa3ee
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 51 deletions.
2 changes: 1 addition & 1 deletion constants/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const COMMODITY_SYNTHS = new Set<CurrencyKey | 'XAU' | 'XAG' | 'WTI'>(['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',
Expand Down
8 changes: 3 additions & 5 deletions hooks/useExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -324,7 +324,6 @@ const useExchange = ({
),
[
txProvider,
isQuoteCurrencyETH,
quoteCurrency,
coinGeckoPrices,
quoteCurrencyTokenAddress,
Expand All @@ -336,7 +335,7 @@ const useExchange = ({
);

const basePriceRate = useMemo(() => {
return txProvider !== 'synthetix' && !isBaseCurrencyETH && !baseCurrency
return txProvider !== 'synthetix' && !baseCurrency
? coinGeckoPrices != null &&
baseCurrencyTokenAddress != null &&
selectPriceCurrencyRate != null &&
Expand All @@ -352,7 +351,6 @@ const useExchange = ({
);
}, [
txProvider,
isBaseCurrencyETH,
baseCurrency,
coinGeckoPrices,
baseCurrencyTokenAddress,
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
];
},
},
]);
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwenta",
"version": "3.0.3",
"version": "3.1.0",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
2 changes: 1 addition & 1 deletion pages/exchange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Exchange: ExchangeComponent = () => {
<ExchangeContext.Provider value={exchangeData}>
<Head>
<title>
{baseCurrencyKey != null && quoteCurrencyKey != null
{!!baseCurrencyKey && !!quoteCurrencyKey && inverseRate.gt(0)
? t('exchange.page-title-currency-pair', {
baseCurrencyKey,
quoteCurrencyKey,
Expand Down
2 changes: 1 addition & 1 deletion pages/leaderboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Leader: LeaderComponent = () => {
</MobileHiddenView>
<MobileOnlyView>
<MobileMainContent>
<Leaderboard />
<Leaderboard mobile />
</MobileMainContent>
</MobileOnlyView>
</PageContent>
Expand Down
7 changes: 6 additions & 1 deletion queries/rates/useExchangeRatesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions sections/futures/Trade/MarketActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -28,15 +30,20 @@ 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
>
{t('futures.market.trade.button.deposit')}
</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
>
Expand Down
20 changes: 9 additions & 11 deletions sections/leaderboard/AllTime/AllTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) =>
Expand All @@ -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 (
Expand Down
31 changes: 14 additions & 17 deletions sections/leaderboard/Competition/Competition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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 =
Expand Down Expand Up @@ -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>
),
Expand Down
18 changes: 10 additions & 8 deletions sections/leaderboard/Leaderboard/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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')};
`;

Expand Down
2 changes: 1 addition & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
"from": "from",
"into": "into"
},
"synth-exchange": "Synth Exchange",
"synth-exchange": "Spot Exchange",
"currency-card": {
"synth-name": "-",
"amount-placeholder": "0.0000",
Expand Down

1 comment on commit 0daa3ee

@vercel
Copy link

@vercel vercel bot commented on 0daa3ee Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kwenta – ./

kwenta.io
kwenta-git-main-kwenta.vercel.app
kwenta-kwenta.vercel.app
v2.beta.kwenta.io

Please sign in to comment.