Skip to content

Commit

Permalink
v3.1.3
Browse files Browse the repository at this point in the history
v3.1.3
  • Loading branch information
platschi authored Sep 1, 2022
2 parents c88fa9b + 5727a7a commit d81d792
Show file tree
Hide file tree
Showing 41 changed files with 271 additions and 206 deletions.
3 changes: 2 additions & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ NEXT_PUBLIC_PORTIS_APP_ID="PORTIS_APP_ID"
NEXT_PUBLIC_BN_NOTIFY_API_KEY="BLOCKNATIVE_NOTIFY_API_KEY"
NEXT_PUBLIC_BN_ONBOARD_API_KEY="BLOCKNATIVE_ONBOARD_API_KEY"
NEXT_PUBLIC_INFURA_PROJECT_ID="INFURA_PROJECT_ID"
NEXT_PUBLIC_BLASTAPI_PROJECT_ID="BLASTAPI_PROJECT_ID"
NEXT_PUBLIC_BLASTAPI_PROJECT_ID="BLASTAPI_PROJECT_ID"
NEXT_PUBLIC_COMPETITION_ACTIVE=false
2 changes: 1 addition & 1 deletion .github/workflows/audit_build_verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Upload lint results
# run if lint failed and only on main/dev branch and pull requests
if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request')
uses: github/codeql-action/upload-sarif@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # pin@codeql-bundle-20220322
with:
sarif_file: lint-results.sarif
continue-on-error: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # pin@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
uses: github/codeql-action/init@b398f525a5587552e573b247ac661067fafa920b # pin@codeql-bundle-20220322
with:
queries: security-and-quality
languages: javascript

- name: Autobuild
uses: github/codeql-action/autobuild@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
uses: github/codeql-action/autobuild@b398f525a5587552e573b247ac661067fafa920b # pin@codeql-bundle-20220322

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
uses: github/codeql-action/analyze@b398f525a5587552e573b247ac661067fafa920b # pin@codeql-bundle-20220322
Binary file modified assets/png/currencies/sDOGE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/png/currencies/sDebt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions components/Currency/CurrencyIcon/CurrencyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AVAXIcon from 'assets/png/currencies/sAVAX.png';
import BNBIcon from 'assets/png/currencies/sBNB.png';
import BTCIcon from 'assets/png/currencies/sBTC.png';
import CHFIcon from 'assets/png/currencies/sCHF.png';
import DEBTIcon from 'assets/png/currencies/sDebt.png';
import DOGEIcon from 'assets/png/currencies/sDOGE.png';
import DOTIcon from 'assets/png/currencies/sDOT.png';
import DYDXIcon from 'assets/png/currencies/sDYDX.png';
Expand Down Expand Up @@ -92,6 +93,7 @@ const SYNTH_ICONS: Record<FuturesMarketKey | SynthsName | string, any> = {
sAUD: AUDIcon,
sBNB: BNBIcon,
sDOGE: DOGEIcon,
sDebtRatio: DEBTIcon,
[CRYPTO_CURRENCY_MAP.SNX]: SNXIcon,
};

Expand Down
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.1.2",
"version": "3.1.3",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
6 changes: 2 additions & 4 deletions queries/futures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ETH_UNIT } from 'constants/network';
import { MarketClosureReason } from 'hooks/useMarketClosed';
import { SynthsTrades, SynthsVolumes } from 'queries/synths/type';
import { Network } from 'store/wallet';
import { formatCurrency, zeroBN } from 'utils/formatters/number';
import { formatDollars, zeroBN } from 'utils/formatters/number';
import { FuturesMarketAsset } from 'utils/futures';

import { FUTURES_ENDPOINT_MAINNET, FUTURES_ENDPOINT_TESTNET, SECONDS_PER_DAY } from './constants';
Expand Down Expand Up @@ -279,9 +279,7 @@ export const mapMarginTransfers = (
const sizeWei = new Wei(size);
const cleanSize = sizeWei.div(ETH_UNIT).abs();
const isPositive = sizeWei.gt(0);
const amount = `${isPositive ? '+' : '-'}${formatCurrency('sUSD', cleanSize, {
sign: '$',
})}`;
const amount = `${isPositive ? '+' : '-'}${formatDollars(cleanSize)}`;
const numTimestamp = wei(timestamp).toNumber();

return {
Expand Down
5 changes: 4 additions & 1 deletion sections/dashboard/DashboardLayout/DashboardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRouter } from 'next/router';
import { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';

import NavButton from 'components/Button/NavButton';
Expand All @@ -9,6 +10,7 @@ import { TabList, TabPanel } from 'components/Tab';
import ROUTES from 'constants/routes';
import Leaderboard from 'sections/leaderboard/Leaderboard';
import AppLayout from 'sections/shared/Layout/AppLayout';
import { isCompetitionActive } from 'store/ui';
import { MainContent, LeftSideContent, FullHeightContainer, PageContent } from 'styles/common';

import Links from '../Links';
Expand All @@ -25,6 +27,7 @@ enum Tab {
const Tabs = Object.values(Tab);

const DashboardLayout: FC = ({ children }) => {
const competitionActive = useRecoilValue(isCompetitionActive);
const { t } = useTranslation();
const router = useRouter();

Expand Down Expand Up @@ -127,7 +130,7 @@ const DashboardLayout: FC = ({ children }) => {
{children}
</TabPanel>
</MainContent>
<Leaderboard compact />
{competitionActive && <Leaderboard compact />}
</StyledFullHeightContainer>
</PageContent>
</DesktopOnlyView>
Expand Down
10 changes: 3 additions & 7 deletions sections/dashboard/FuturesHistoryTable/FuturesHistoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import useGetAllFuturesTradesForAccount from 'queries/futures/useGetAllFuturesTr
import { TradeStatus } from 'sections/futures/types';
import { futuresAccountState } from 'store/futures';
import { isL2State } from 'store/wallet';
import { formatCryptoCurrency, formatCurrency } from 'utils/formatters/number';
import { formatCryptoCurrency, formatDollars } from 'utils/formatters/number';
import { FuturesMarketAsset, getMarketName, isDecimalFour, MarketKeyByAsset } from 'utils/futures';

import TimeDisplay from '../../futures/Trades/TimeDisplay';
Expand Down Expand Up @@ -155,7 +155,7 @@ const FuturesHistoryTable: FC = () => {
: { sign: '$' };
return conditionalRender(
cellProps.row.original.price,
<>{formatCurrency('sUSD', cellProps.value, formatOptions)}</>
<>{formatDollars(cellProps.value, formatOptions)}</>
);
},
width: 120,
Expand All @@ -169,11 +169,7 @@ const FuturesHistoryTable: FC = () => {
cellProps.row.original.pnl.eq(wei(0)) ? (
<PNL normal>--</PNL>
) : (
<PNL negative={cellProps.value.lt(wei(0))}>
{formatCurrency('sUSD', cellProps.value, {
sign: '$',
})}
</PNL>
<PNL negative={cellProps.value.lt(wei(0))}>{formatDollars(cellProps.value)}</PNL>
)
);
},
Expand Down
8 changes: 3 additions & 5 deletions sections/dashboard/MobileDashboard/FuturesMarkets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRecoilValue } from 'recoil';
import useGetFuturesDailyTradeStats from 'queries/futures/useGetFuturesDailyTradeStats';
import { SectionHeader, SectionTitle } from 'sections/futures/MobileTrade/common';
import { futuresMarketsState } from 'store/futures';
import { formatCurrency, formatNumber, zeroBN } from 'utils/formatters/number';
import { formatDollars, formatNumber, zeroBN } from 'utils/formatters/number';

import FuturesMarketsTable from '../FuturesMarketsTable';
import { HeaderContainer, MarketStatsContainer, MarketStat } from './common';
Expand Down Expand Up @@ -32,17 +32,15 @@ const FuturesMarkets = () => {
<MarketStat>
<div className="title">24h Volume</div>
<div className="value">
{formatCurrency('sUSD', dailyTradeStats.data?.totalVolume ?? zeroBN, {
sign: '$',
{formatDollars(dailyTradeStats.data?.totalVolume ?? zeroBN, {
minDecimals: 0,
})}
</div>
</MarketStat>
<MarketStat>
<div className="title">Open Interest</div>
<div className="value">
{formatCurrency('sUSD', openInterest, {
sign: '$',
{formatDollars(openInterest, {
minDecimals: 0,
})}
</div>
Expand Down
12 changes: 3 additions & 9 deletions sections/dashboard/MobileDashboard/OpenPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useGetCurrentPortfolioValue from 'queries/futures/useGetCurrentPortfolioV
import useGetFuturesPositionForAccount from 'queries/futures/useGetFuturesPositionForAccount';
import { SectionHeader, SectionTitle } from 'sections/futures/MobileTrade/common';
import { walletAddressState } from 'store/wallet';
import { formatCurrency, zeroBN } from 'utils/formatters/number';
import { formatDollars, zeroBN } from 'utils/formatters/number';

import FuturesPositionsTable from '../FuturesPositionsTable';
import SynthBalancesTable from '../SynthBalancesTable';
Expand Down Expand Up @@ -46,15 +46,9 @@ const OpenPositions: React.FC = () => {
PositionsTab.FUTURES
);

const totalSpotBalancesValue = formatCurrency(
'sUSD',
wei(synthBalances?.totalUSDBalance ?? zeroBN),
{ sign: '$' }
);
const totalSpotBalancesValue = formatDollars(wei(synthBalances?.totalUSDBalance ?? zeroBN));

const totalFuturesPortfolioValue = formatCurrency('sUSD', wei(portfolioValue ?? zeroBN), {
sign: '$',
});
const totalFuturesPortfolioValue = formatDollars(wei(portfolioValue ?? zeroBN));

const POSITIONS_TABS = React.useMemo(
() => [
Expand Down
8 changes: 3 additions & 5 deletions sections/dashboard/MobileDashboard/SynthMarkets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRecoilValue } from 'recoil';
import useGetFuturesDailyTradeStats from 'queries/futures/useGetFuturesDailyTradeStats';
import { SectionHeader, SectionTitle } from 'sections/futures/MobileTrade/common';
import { futuresMarketsState } from 'store/futures';
import { formatCurrency, formatNumber, zeroBN } from 'utils/formatters/number';
import { formatDollars, formatNumber, zeroBN } from 'utils/formatters/number';

import SpotMarketsTable from '../SpotMarketsTable';
import { HeaderContainer, MarketStatsContainer, MarketStat } from './common';
Expand Down Expand Up @@ -36,17 +36,15 @@ const SynthMarkets: React.FC = () => {
<MarketStat>
<div className="title">24h Volume</div>
<div className="value">
{formatCurrency('sUSD', dailyTradeStats.data?.totalVolume || zeroBN, {
sign: '$',
{formatDollars(dailyTradeStats.data?.totalVolume || zeroBN, {
minDecimals: 0,
})}
</div>
</MarketStat>
<MarketStat>
<div className="title">Open Interest</div>
<div className="value">
{formatCurrency('sUSD', openInterest ?? 0, {
sign: '$',
{formatDollars(openInterest ?? 0, {
minDecimals: 0,
})}
</div>
Expand Down
12 changes: 3 additions & 9 deletions sections/dashboard/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useGetCurrentPortfolioValue from 'queries/futures/useGetCurrentPortfolioV
import useGetFuturesPositionForAccount from 'queries/futures/useGetFuturesPositionForAccount';
import { CompetitionBanner } from 'sections/shared/components/CompetitionBanner';
import { walletAddressState } from 'store/wallet';
import { formatCurrency, zeroBN } from 'utils/formatters/number';
import { formatDollars, zeroBN } from 'utils/formatters/number';

import FuturesMarketsTable from '../FuturesMarketsTable';
import FuturesPositionsTable from '../FuturesPositionsTable';
Expand Down Expand Up @@ -56,15 +56,9 @@ const Overview: FC = () => {
const [activePositionsTab, setActivePositionsTab] = useState<PositionsTab>(PositionsTab.FUTURES);
const [activeMarketsTab, setActiveMarketsTab] = useState<MarketsTab>(MarketsTab.FUTURES);

const totalSpotBalancesValue = formatCurrency(
'sUSD',
wei(synthBalances?.totalUSDBalance ?? zeroBN),
{ sign: '$' }
);
const totalSpotBalancesValue = formatDollars(wei(synthBalances?.totalUSDBalance ?? zeroBN));

const totalFuturesPortfolioValue = formatCurrency('sUSD', wei(portfolioValue ?? zeroBN), {
sign: '$',
});
const totalFuturesPortfolioValue = formatDollars(wei(portfolioValue ?? zeroBN));

const POSITIONS_TABS = useMemo(
() => [
Expand Down
9 changes: 3 additions & 6 deletions sections/exchange/MobileSwap/SwapInfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { NO_VALUE } from 'constants/placeholder';
import { useExchangeContext } from 'contexts/ExchangeContext';
import { parseGasPriceObject } from 'hooks/useGas';
import { customGasPriceState, gasSpeedState, isL2State, isMainnetState } from 'store/wallet';
import { formatCurrency, formatNumber, formatPercent, zeroBN } from 'utils/formatters/number';
import { formatDollars, formatNumber, formatPercent, zeroBN } from 'utils/formatters/number';

const SwapInfoBox: React.FC = () => {
const { t } = useTranslation();
Expand All @@ -33,9 +33,7 @@ const SwapInfoBox: React.FC = () => {
const gasPrice = gasPrices ? parseGasPriceObject(gasPrices[gasSpeed]) : null;

const formattedTransactionFee = React.useMemo(() => {
return transactionFee
? formatCurrency('sUSD', transactionFee, { sign: '$', maxDecimals: 1 })
: NO_VALUE;
return transactionFee ? formatDollars(transactionFee, { maxDecimals: 1 }) : NO_VALUE;
}, [transactionFee]);

const gasPriceItem = isL2
Expand Down Expand Up @@ -82,8 +80,7 @@ const SwapInfoBox: React.FC = () => {
[t('common.summary.fee-cost')]: {
value:
feeCost != null
? formatCurrency('sUSD', feeCost, {
sign: '$',
? formatDollars(feeCost, {
minDecimals: feeCost.lt(0.01) ? 4 : 2,
})
: NO_VALUE,
Expand Down
8 changes: 3 additions & 5 deletions sections/futures/MarketDetails/MarketDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimerTooltip from 'components/Tooltip/TimerTooltip';
import useRateUpdateQuery from 'queries/rates/useRateUpdateQuery';
import { currentMarketState, marketInfoState } from 'store/futures';
import media from 'styles/media';
import { formatCurrency, formatPercent } from 'utils/formatters/number';
import { formatDollars, formatPercent } from 'utils/formatters/number';

import useGetMarketData from './useGetMarketData';

Expand Down Expand Up @@ -38,8 +38,7 @@ const MarketDetails: React.FC<MarketDetailsProps> = ({ mobile }) => {
const longText = useMemo(() => {
return (
marketInfo?.openInterest &&
formatCurrency('sUSD', marketInfo.openInterest.longUSD, {
sign: '$',
formatDollars(marketInfo.openInterest.longUSD, {
maxDecimals: 2,
...(marketInfo?.openInterest?.longUSD.gt(1e6)
? { truncation: { divisor: 1e6, unit: 'M' } }
Expand All @@ -51,8 +50,7 @@ const MarketDetails: React.FC<MarketDetailsProps> = ({ mobile }) => {
const shortText = useMemo(() => {
return (
marketInfo?.openInterest &&
formatCurrency('sUSD', marketInfo.openInterest.shortUSD, {
sign: '$',
formatDollars(marketInfo.openInterest.shortUSD, {
maxDecimals: 2,
...(marketInfo?.openInterest?.shortUSD.gt(1e6)
? { truncation: { divisor: 1e6, unit: 'M' } }
Expand Down
19 changes: 6 additions & 13 deletions sections/futures/MarketInfoBox/MarketInfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
tradeSizeState,
} from 'store/futures';
import { computeNPFee } from 'utils/costCalculations';
import { formatCurrency, formatPercent, zeroBN } from 'utils/formatters/number';
import { formatDollars, formatPercent, zeroBN } from 'utils/formatters/number';

import { PositionSide } from '../types';

Expand Down Expand Up @@ -124,34 +124,27 @@ const MarketInfoBox: React.FC = () => {
dataTestId="market-info-box"
details={{
'Total Margin': {
value: `${formatCurrency('sUSD', totalMargin, {
value: `${formatDollars(totalMargin, {
currencyKey: 'sUSD',
sign: '$',
})}`,
},
'Available Margin': {
value: `${formatCurrency('sUSD', availableMargin, {
value: `${formatDollars(availableMargin, {
currencyKey: undefined,
sign: '$',
})}`,
valueNode: (
<PreviewArrow showPreview={previewTradeData.showPreview && !previewTrade?.showStatus}>
{formatCurrency('sUSD', previewTradeData?.availableMargin, {
sign: '$',
})}
{formatDollars(previewTradeData?.availableMargin)}
</PreviewArrow>
),
},
'Buying Power': {
value: `${formatCurrency('sUSD', buyingPower, {
value: `${formatDollars(buyingPower, {
currencyKey: undefined,
sign: '$',
})}`,
valueNode: previewTradeData?.buyingPower && (
<PreviewArrow showPreview={previewTradeData.showPreview && !previewTrade?.showStatus}>
{formatCurrency('sUSD', previewTradeData?.buyingPower, {
sign: '$',
})}
{formatDollars(previewTradeData?.buyingPower)}
</PreviewArrow>
),
},
Expand Down
Loading

1 comment on commit d81d792

@vercel
Copy link

@vercel vercel bot commented on d81d792 Sep 1, 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-git-main-kwenta.vercel.app
kwenta.io
v2.beta.kwenta.io
kwenta-kwenta.vercel.app

Please sign in to comment.