Skip to content

Commit

Permalink
v3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
platschi authored Aug 29, 2022
2 parents 22f2808 + d91d624 commit c88fa9b
Show file tree
Hide file tree
Showing 109 changed files with 3,844 additions and 2,095 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/audit_build_verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
continue-on-error: true

- name: Cache node modules
uses: actions/cache@a7c34adf76222e77931dedbf4a45b2e4648ced19 # pin@v3
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v3
with:
path: |
.npm-cache
Expand Down 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@2ca79b6fa8d3ec278944088b4aa5f46912db5d63 # pin@codeql-bundle-20220322
uses: github/codeql-action/upload-sarif@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
with:
sarif_file: lint-results.sarif
continue-on-error: true
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
continue-on-error: true

- name: Cache node modules
uses: actions/cache@a7c34adf76222e77931dedbf4a45b2e4648ced19 # pin@v3
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v3
with:
path: |
.npm-cache
Expand All @@ -119,7 +119,7 @@ jobs:
npm install --prefer-offline --no-audit --legacy-peer-deps
- name: Cache next.js build cache
uses: actions/cache@a7c34adf76222e77931dedbf4a45b2e4648ced19 # pin@v2
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v2
with:
path: .next/cache
key: ${{ runner.os }}-next-cache-${{ hashFiles('**/package-lock.json') }}
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@2ca79b6fa8d3ec278944088b4aa5f46912db5d63 # pin@codeql-bundle-20220322
uses: github/codeql-action/init@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
with:
queries: security-and-quality
languages: javascript

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2ca79b6fa8d3ec278944088b4aa5f46912db5d63 # pin@codeql-bundle-20220322
uses: github/codeql-action/analyze@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20220322
Binary file modified assets/png/currencies/SNX.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 modified assets/png/currencies/sAAVE.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 modified assets/png/currencies/sADA.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 modified assets/png/currencies/sAPECOIN.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 modified assets/png/currencies/sAUD.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 modified assets/png/currencies/sAVAX.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/sBNB.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 modified assets/png/currencies/sBTC.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 modified assets/png/currencies/sCHF.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/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 modified assets/png/currencies/sDOT.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 modified assets/png/currencies/sDYDX.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 modified assets/png/currencies/sETH.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 modified assets/png/currencies/sEUR.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 modified assets/png/currencies/sGBP.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 modified assets/png/currencies/sINR.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 modified assets/png/currencies/sJPY.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 modified assets/png/currencies/sKRW.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 modified assets/png/currencies/sLINK.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 modified assets/png/currencies/sMATIC.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 modified assets/png/currencies/sOIL.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 modified assets/png/currencies/sSOL.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 modified assets/png/currencies/sUNI.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 modified assets/png/currencies/sUSD.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 modified assets/png/currencies/sXAG.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 modified assets/png/currencies/sXAU.png
6 changes: 5 additions & 1 deletion components/Currency/CurrencyIcon/CurrencyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import ADAIcon from 'assets/png/currencies/sADA.png';
import APEIcon from 'assets/png/currencies/sAPECOIN.png';
import AUDIcon from 'assets/png/currencies/sAUD.png';
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 DOGEIcon from 'assets/png/currencies/sDOGE.png';
import DOTIcon from 'assets/png/currencies/sDOT.png';
import DYDXIcon from 'assets/png/currencies/sDYDX.png';
import ETHIcon from 'assets/png/currencies/sETH.png';
Expand Down Expand Up @@ -88,6 +90,8 @@ const SYNTH_ICONS: Record<FuturesMarketKey | SynthsName | string, any> = {
sETHBTC: ETHBTCIcon,
sADA: ADAIcon,
sAUD: AUDIcon,
sBNB: BNBIcon,
sDOGE: DOGEIcon,
[CRYPTO_CURRENCY_MAP.SNX]: SNXIcon,
};

Expand Down Expand Up @@ -151,7 +155,7 @@ const CurrencyIcon: FC<CurrencyIconProps> = ({ currencyKey, type, isDeprecated,
} else {
return (
<Placeholder {...{ isDeprecated }} {...props}>
{currencyKey}
{currencyKey === 'sDebtRatio' ? 'DEBT' : currencyKey}
</Placeholder>
);
}
Expand Down
9 changes: 4 additions & 5 deletions components/TVChart/DataFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
SubscribeBarsCallback,
} from 'public/static/charting_library/charting_library';

import { Synths } from 'constants/currency';
import { requestCandlesticks } from 'queries/rates/useCandlesticksQuery';
import { combineDataToPair } from 'sections/exchange/TradeCard/Charts/hooks/useCombinedCandleSticksChartData';
import { getDisplayAsset } from 'utils/futures';
Expand Down Expand Up @@ -55,8 +54,8 @@ const fetchCombinedCandles = async (
resolution: ResolutionString,
networkId: number
) => {
const baseCurrencyIsSUSD = base === Synths.sUSD;
const quoteCurrencyIsSUSD = quote === Synths.sUSD;
const baseCurrencyIsSUSD = base === 'sUSD';
const quoteCurrencyIsSUSD = quote === 'sUSD';
const baseDataPromise = requestCandlesticks(
base,
from,
Expand All @@ -83,8 +82,8 @@ const fetchLastCandle = async (
resolution: ResolutionString,
networkId: number
) => {
const baseCurrencyIsSUSD = base === Synths.sUSD;
const quoteCurrencyIsSUSD = quote === Synths.sUSD;
const baseCurrencyIsSUSD = base === 'sUSD';
const quoteCurrencyIsSUSD = quote === 'sUSD';
const to = Math.floor(Date.now() / 1000);
const from = 0;

Expand Down
5 changes: 2 additions & 3 deletions components/TVChart/TVChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useRef, useContext, useEffect, useCallback, useState, useMemo } from 'r
import { useRecoilValue } from 'recoil';
import { ThemeContext } from 'styled-components';

import { Synths } from 'constants/currency';
import { ChartBody } from 'sections/exchange/TradeCard/Charts/common/styles';
import { currentThemeState } from 'store/ui';
import { networkState } from 'store/wallet';
Expand Down Expand Up @@ -70,7 +69,7 @@ export function TVChart({

useEffect(() => {
const widgetOptions = {
symbol: marketAsset + ':' + Synths.sUSD,
symbol: marketAsset + ':sUSD',
datafeed: DataFeedFactory(network.id, onSubscribe),
interval: interval,
container: containerId,
Expand Down Expand Up @@ -180,7 +179,7 @@ export function TVChart({
_widget.current?.onChartReady(() => {
const symbolInterval = _widget.current?.symbolInterval();
_widget.current?.setSymbol(
marketAsset + ':' + Synths.sUSD,
marketAsset + ':sUSD',
symbolInterval?.interval ?? DEFAULT_RESOLUTION,
() => {}
);
Expand Down
15 changes: 8 additions & 7 deletions constants/currency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CurrencyKey } from '@synthetixio/contracts-interface';
import { Synths } from '@synthetixio/contracts-interface';
import Wei from '@synthetixio/wei';
import keyBy from 'lodash/keyBy';

Expand Down Expand Up @@ -44,12 +43,12 @@ export const CRYPTO_CURRENCY = [
export const CRYPTO_CURRENCY_MAP = keyBy(CRYPTO_CURRENCY);
export type FUTURES_FIAT = 'EUR' | 'JPY' | 'USD' | 'AUD' | 'GBP' | 'CHF';
export const FIAT_SYNTHS: Set<CurrencyKey | FUTURES_FIAT> = new Set([
Synths.sEUR,
Synths.sJPY,
Synths.sUSD,
Synths.sAUD,
Synths.sGBP,
Synths.sCHF,
'sEUR',
'sJPY',
'sUSD',
'sAUD',
'sGBP',
'sCHF',
'EUR',
'JPY',
'USD',
Expand All @@ -74,6 +73,8 @@ export const MARKET_HOURS_SYNTHS = new Set([
// Commodity synths are not listed in the CurrencyKey currently. This is a temporary workaround.
export const COMMODITY_SYNTHS = new Set<CurrencyKey | 'XAU' | 'XAG' | 'WTI'>(['XAU', 'XAG', 'WTI']);

export const INDEX_SYNTHS = new Set<CurrencyKey | 'DebtRatio'>(['DebtRatio']);

export const sUSD_EXCHANGE_RATE = new Wei(1);
export const SYNTH_DECIMALS = 18;

Expand Down
1 change: 0 additions & 1 deletion constants/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const DEFAULT_SEARCH_DEBOUNCE_MS = 300;
export const DEFAULT_REQUEST_REFRESH_INTERVAL = 30000; // 30s
export const DEFAULT_CRYPTO_DECIMALS = 4;
export const DEFAULT_FIAT_DECIMALS = 2;
export const DEFAULT_FIAT_EURO_DECIMALS = 4;
export const DEFAULT_NUMBER_DECIMALS = 2;
export const DEFAULT_PERCENT_DECIMALS = 2;
export const DEFAULT_TOKEN_DECIMALS = 18;
Expand Down
2 changes: 2 additions & 0 deletions constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumber } from 'ethers';
export const GWEI_UNIT = 1000000000;
export const GWEI_DECIMALS = 9;
export const ETH_UNIT = 1000000000000000000;
export const DEBT_RATIO_UNIT = 10000000000000000000;

export type GasLimitEstimate = BigNumber | null;

Expand All @@ -11,6 +12,7 @@ export const SUPPORTED_NETWORKS = [
10, // Optimism (mainnet)
42, // Ethereum Kovan (testnet)
69, // Optimism Kovan (testnet)
420, // Optimism Goerli (testnet)
];

export enum BlastNetwork {
Expand Down
31 changes: 22 additions & 9 deletions hooks/useExchange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useSynthetixQueries from '@synthetixio/queries';
import useSynthetixQueries, { Token } from '@synthetixio/queries';
import Wei, { wei } from '@synthetixio/wei';
import { BigNumber, ethers } from 'ethers';
import produce from 'immer';
Expand All @@ -14,7 +14,6 @@ import {
CRYPTO_CURRENCY_MAP,
CurrencyKey,
ETH_ADDRESS,
Synths,
} from 'constants/currency';
import { DEFAULT_CRYPTO_DECIMALS } from 'constants/defaults';
import ROUTES from 'constants/routes';
Expand Down Expand Up @@ -55,7 +54,11 @@ import {
networkState,
gasSpeedState,
} from 'store/wallet';
import { newGetExchangeRatesForCurrencies } from 'utils/currencies';
import {
newGetCoinGeckoPricesForCurrencies,
newGetExchangeRatesForCurrencies,
newGetExchangeRatesTupleForCurrencies,
} from 'utils/currencies';
import { truncateNumbers, zeroBN } from 'utils/formatters/number';
import { hexToAsciiV2 } from 'utils/formatters/string';
import logError from 'utils/logError';
Expand Down Expand Up @@ -190,7 +193,7 @@ const useExchange = ({
: null;

const quoteCurrencyTokenAddress = useMemo(
() =>
(): Token['address'] | null =>
quoteCurrencyKey != null
? isQuoteCurrencyETH
? ETH_ADDRESS
Expand All @@ -200,7 +203,7 @@ const useExchange = ({
);

const baseCurrencyTokenAddress = useMemo(
() =>
(): Token['address'] | null =>
baseCurrencyKey != null
? isBaseCurrencyETH
? ETH_ADDRESS
Expand Down Expand Up @@ -273,11 +276,21 @@ const useExchange = ({

const exchangeRates = exchangeRatesQuery.isSuccess ? exchangeRatesQuery.data ?? null : null;

const rate = useMemo(
() => newGetExchangeRatesForCurrencies(exchangeRates, quoteCurrencyKey, baseCurrencyKey),
const [quoteRate, baseRate] = useMemo(
() => newGetExchangeRatesTupleForCurrencies(exchangeRates, quoteCurrencyKey, baseCurrencyKey),
[exchangeRates, quoteCurrencyKey, baseCurrencyKey]
);

const rate = useMemo(() => {
const base = baseRate.lte(0)
? newGetCoinGeckoPricesForCurrencies(coinGeckoPrices, baseCurrencyTokenAddress)
: baseRate;
const quote = quoteRate.lte(0)
? newGetCoinGeckoPricesForCurrencies(coinGeckoPrices, quoteCurrencyTokenAddress)
: quoteRate;
return base.gt(0) && quote.gt(0) ? quote.div(base) : wei(0);
}, [baseCurrencyTokenAddress, baseRate, coinGeckoPrices, quoteCurrencyTokenAddress, quoteRate]);

const inverseRate = useMemo(() => (rate.gt(0) ? wei(1).div(rate) : wei(0)), [rate]);

const getBalance = useCallback(
Expand Down Expand Up @@ -372,7 +385,7 @@ const useExchange = ({
: null;

const ethPriceRate = useMemo(
() => newGetExchangeRatesForCurrencies(exchangeRates, Synths.sETH, selectedPriceCurrency.name),
() => newGetExchangeRatesForCurrencies(exchangeRates, 'sETH', selectedPriceCurrency.name),
[exchangeRates, selectedPriceCurrency.name]
);

Expand Down Expand Up @@ -497,7 +510,7 @@ const useExchange = ({

setCurrencyPair({
base: (baseCurrencyKey && synthsMap[baseCurrencyKey]?.name) || null,
quote: (quoteCurrencyKey && synthsMap[quoteCurrencyKey]?.name) || Synths.sUSD,
quote: (quoteCurrencyKey && synthsMap[quoteCurrencyKey]?.name) || 'sUSD',
});
// eslint-disable-next-line
}, [network.id, walletAddress, setCurrencyPair, synthsMap]);
Expand Down
Loading

1 comment on commit c88fa9b

@vercel
Copy link

@vercel vercel bot commented on c88fa9b Aug 29, 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-kwenta.vercel.app
kwenta-git-main-kwenta.vercel.app
v2.beta.kwenta.io

Please sign in to comment.