Skip to content

Commit

Permalink
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
Browse files Browse the repository at this point in the history
…-interface into feat/stop-loss-with-autonomy-bot
  • Loading branch information
unbreakablery committed Aug 9, 2022
2 parents b763dd2 + 3df11ea commit 6806495
Show file tree
Hide file tree
Showing 22 changed files with 215 additions and 125 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@
"@sentry/nextjs": "^7.0.0",
"@sentry/react": "^7.0.0",
"@sentry/tracing": "^7.0.0",
"@sushiswap/bentobox-sdk": "1.0.0-canary.109",
"@sushiswap/bentobox-sdk": "1.0.0-canary.112",
"@sushiswap/chainlink-whitelist": "0.2.8",
"@sushiswap/core": "^2.0.0-canary.1",
"@sushiswap/core-sdk": "1.0.0-canary.128",
"@sushiswap/kashi-sdk": "1.0.0-canary.100",
"@sushiswap/core-sdk": "1.0.0-canary.131",
"@sushiswap/kashi-sdk": "1.0.0-canary.103",
"@sushiswap/limit-order-pair-list": "0.2.17",
"@sushiswap/limit-order-sdk": "1.0.0-canary.109",
"@sushiswap/limit-order-sdk": "1.0.0-canary.112",
"@sushiswap/miso": "1.0.0-canary.47",
"@sushiswap/miso-sdk": "1.0.0-canary.98",
"@sushiswap/miso-sdk": "1.0.0-canary.101",
"@sushiswap/trident": "^1.0.0-canary.40",
"@sushiswap/trident-sdk": "1.0.0-canary.137",
"@sushiswap/trident-sdk": "1.0.0-canary.140",
"@testing-library/jest-dom": "^5.14.0",
"@testing-library/react": "^12.1.0",
"@transak/transak-sdk": "^1.0.31",
Expand Down
2 changes: 2 additions & 0 deletions src/components/CurrencyLogo/CurrencyLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BLOCKCHAIN = {
[ChainId.MOONBEAM]: 'moonbeam',
[ChainId.KAVA]: 'kava',
[ChainId.METIS]: 'metis',
[ChainId.ARBITRUM_NOVA]: 'arbitrum-nova',
[ChainId.HARDHAT]: 'hardhat',
}

Expand Down Expand Up @@ -116,6 +117,7 @@ const LOGO: Record<ChainId, string> = {
[ChainId.OPTIMISM]: EthereumLogo,
[ChainId.KAVA]: KavaLogo,
[ChainId.METIS]: MetisLogo,
[ChainId.ARBITRUM_NOVA]: EthereumLogo,
}

export interface CurrencyLogoProps {
Expand Down
44 changes: 30 additions & 14 deletions src/components/Web3Network/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import useIsWindowVisible from 'app/hooks/useIsWindowVisible'
import usePrevious from 'app/hooks/usePrevious'
import NetworkModel from 'app/modals/NetworkModal'
import { useActiveWeb3React } from 'app/services/web3'
import { useNetworkModalToggle } from 'app/state/application/hooks'
import { useModalOpen, useNetworkModalToggle } from 'app/state/application/hooks'
import { ApplicationModal } from 'app/state/application/reducer'
import Cookies from 'js-cookie'
import Image from 'next/image'
import { useRouter } from 'next/router'
Expand All @@ -27,25 +28,33 @@ function Web3Network(): JSX.Element | null {

const queryChainId = Number(router.query.chainId)

const networkModalOpen = useModalOpen(ApplicationModal.NETWORK)

const handleChainSwitch = useCallback(
(targetChain: number) => {
if (!library || !library?.provider) {
setAttemptingSwitchFromUrl(false)
return
}

setSwitchedFromUrl(true)

if (switchedFromUrl) return

switchToNetwork({ provider: library.provider, chainId: targetChain }).then(() => {
return router.replace({
pathname: router.pathname,
query: { ...router.query, chainId: targetChain },
switchToNetwork({ provider: library.provider, chainId: targetChain })
.then(() => {
return router.replace(
{
pathname: router.pathname,
query: { ...router.query, chainId: targetChain },
},
undefined,
{ shallow: true }
)
})
.finally(() => {
if (networkModalOpen) {
toggleNetworkModal()
}
})
})
},
[library, switchedFromUrl, router]
[library, router, toggleNetworkModal, networkModalOpen]
)

useEffect(() => {
Expand All @@ -54,7 +63,7 @@ function Web3Network(): JSX.Element | null {
// when network change originates from wallet or dropdown selector, just update URL
if (chainId !== prevChainId) {
console.debug('network change from wallet or network modal')
router.replace({ pathname: router.pathname, query: { ...router.query, chainId } })
router.replace({ pathname: router.pathname, query: { ...router.query, chainId } }, undefined, { shallow: true })
}
}, [chainId, prevChainId, router])

Expand All @@ -75,13 +84,16 @@ function Web3Network(): JSX.Element | null {

console.debug('network change from query chainId', { queryChainId, defaultChainId, chainId })
setAttemptingSwitchFromUrl(true)
setSwitchedFromUrl(true)
if (switchedFromUrl) return

handleChainSwitch(defaultChainId ? defaultChainId : queryChainId)
}, [chainId, handleChainSwitch, switchedFromUrl, queryChainId, isWindowVisible, attemptingSwitchFromUrl])

// set chainId on initial load if not present
useEffect(() => {
if (chainId && !queryChainId) {
router.replace({ pathname: router.pathname, query: { ...router.query, chainId } })
router.replace({ pathname: router.pathname, query: { ...router.query, chainId } }, undefined, { shallow: true })
}
}, [chainId, queryChainId, router])

Expand All @@ -96,7 +108,11 @@ function Web3Network(): JSX.Element | null {
{/*@ts-ignore TYPE NEEDS FIXING*/}
<Image src={NETWORK_ICON[chainId]} alt="Switch Network" className="rounded-full" width="24px" height="24px" />
</div>
<NetworkModel />
<NetworkModel
switchNetwork={(targetChain: number) => {
handleChainSwitch(targetChain)
}}
/>
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/config/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const features: FeatureMap = {
[ChainId.OPTIMISM]: [Feature.TRIDENT, Feature.BENTOBOX],
[ChainId.KAVA]: [Feature.TRIDENT, Feature.BENTOBOX, Feature.LIQUIDITY_MINING],
[ChainId.METIS]: [Feature.TRIDENT, Feature.BENTOBOX, Feature.LIQUIDITY_MINING],
[ChainId.ARBITRUM_NOVA]: [Feature.AMM],
}

export default features
2 changes: 2 additions & 0 deletions src/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const NETWORK_ICON: Record<number, string> = {
[ChainId.OPTIMISM]: Optimism,
[ChainId.KAVA]: Kava,
[ChainId.METIS]: Metis,
[ChainId.ARBITRUM_NOVA]: Arbitrum,
}

export const NETWORK_LABEL: Record<number, string> = {
Expand Down Expand Up @@ -93,4 +94,5 @@ export const NETWORK_LABEL: Record<number, string> = {
[ChainId.OPTIMISM]: 'Optimism',
[ChainId.KAVA]: 'Kava',
[ChainId.METIS]: 'Metis',
[ChainId.ARBITRUM_NOVA]: 'Arbitrum Nova',
}
32 changes: 16 additions & 16 deletions src/config/oracles/chainlink/mappings/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,14 +1119,14 @@ const MAINNET_CHAINLINK_MAPPING = {
fromDecimals: 18,
toDecimals: 18,
},
// WAVES / USD
'0x9a79fdCd0E326dF6Fa34EA13c05d3106610798E9': {
from: '0x1cF4592ebfFd730c7dc92c1bdFFDfc3B9EfCf29a',
to: '0x0000000000000000000000000000000000000001',
decimals: 8,
fromDecimals: 18,
toDecimals: 8,
},
// // WAVES / USD
// '0x9a79fdCd0E326dF6Fa34EA13c05d3106610798E9': {
// from: '0x1cF4592ebfFd730c7dc92c1bdFFDfc3B9EfCf29a',
// to: '0x0000000000000000000000000000000000000001',
// decimals: 8,
// fromDecimals: 18,
// toDecimals: 8,
// },
// WNXM / ETH
'0xe5Dc0A609Ab8bCF15d3f35cFaa1Ff40f521173Ea': {
from: '0x0d438F3b5175Bebc262bF23753C1E53d03432bDE',
Expand All @@ -1143,14 +1143,14 @@ const MAINNET_CHAINLINK_MAPPING = {
fromDecimals: 18,
toDecimals: 18,
},
// WOO / ETH
'0x926a93B44a887076eDd00257E5D42fafea313363': {
from: '0x4691937a7508860F876c9c0a2a617E7d9E945D4B',
to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
decimals: 18,
fromDecimals: 18,
toDecimals: 18,
},
// // WOO / ETH
// '0x926a93B44a887076eDd00257E5D42fafea313363': {
// from: '0x4691937a7508860F876c9c0a2a617E7d9E945D4B',
// to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
// decimals: 18,
// fromDecimals: 18,
// toDecimals: 18,
// },
// XMR / USD
'0xFA66458Cce7Dd15D8650015c4fce4D278271618F': {
from: '0x465e07d6028830124BE2E4aA551fBe12805dB0f5',
Expand Down
24 changes: 24 additions & 0 deletions src/config/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ChainId, SUSHI, Token, WNATIVE } from '@sushiswap/core-sdk'

import * as ARBITRUM from './tokens/arbitrum'
import * as ARBITRUM_NOVA from './tokens/arbitrum-nova'
import * as AVALANCHE from './tokens/avalanche'
import * as BSC from './tokens/bsc'
import * as CELO from './tokens/celo'
Expand All @@ -20,6 +21,7 @@ import * as OPTIMISM from './tokens/optimism'
import * as PALM from './tokens/palm'
import * as TELOS from './tokens/telos'
import * as XDAI from './tokens/xdai'

type ChainTokenList = {
readonly [chainId: number]: Token[]
}
Expand Down Expand Up @@ -78,6 +80,7 @@ const WRAPPED_NATIVE_ONLY: ChainTokenList = {
[ChainId.OPTIMISM]: [WNATIVE[ChainId.OPTIMISM]],
[ChainId.KAVA]: [WNATIVE[ChainId.KAVA]],
[ChainId.METIS]: [WNATIVE[ChainId.METIS]],
[ChainId.ARBITRUM_NOVA]: [WNATIVE[ChainId.ARBITRUM_NOVA]],
}

// used to construct intermediary pairs for trading
Expand Down Expand Up @@ -246,6 +249,13 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

export const ADDITIONAL_BASES: {
Expand Down Expand Up @@ -643,6 +653,13 @@ export const COMMON_BASES: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

// used to construct the list of all pairs we consider by default in the frontend
Expand Down Expand Up @@ -792,6 +809,13 @@ export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
],
[ChainId.KAVA]: [...WRAPPED_NATIVE_ONLY[ChainId.KAVA], KAVA.USDC, KAVA.USDT, KAVA.WETH, KAVA.WBTC, KAVA.DAI],
[ChainId.METIS]: [...WRAPPED_NATIVE_ONLY[ChainId.METIS], METIS.USDC, METIS.USDT, METIS.WETH, METIS.DAI, METIS.WBTC],
[ChainId.ARBITRUM_NOVA]: [
...WRAPPED_NATIVE_ONLY[ChainId.ARBITRUM_NOVA],
ARBITRUM_NOVA.USDC,
ARBITRUM_NOVA.USDT,
ARBITRUM_NOVA.DAI,
ARBITRUM_NOVA.WBTC,
],
}

export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = {
Expand Down
1 change: 1 addition & 0 deletions src/config/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const RPC = {
[ChainId.OPTIMISM]: 'https://mainnet.optimism.io',
[ChainId.KAVA]: 'https://evm.kava.io',
[ChainId.METIS]: 'https://andromeda.metis.io/?owner=1088',
[ChainId.ARBITRUM_NOVA]: 'https://a4ba.arbitrum.io/rpc',
}

export default RPC
14 changes: 6 additions & 8 deletions src/config/token-lists.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json'
const YEARN_LIST = 'https://yearn.science/static/tokenlist.json'
const NFTX_LIST = 'https://nftx.ethereumdb.com/v2/tokenlist/'
const NFTX_LIST = 'https://tokenlist.nftx.io'
const SYNTHETIX_LIST = 'synths.snx.eth'
const AAVE_LIST = 'tokenlist.aave.eth'
const CMC_ALL_LIST = 'https://api.coinmarketcap.com/data-api/v3/uniswap/all.json'
Expand All @@ -14,7 +13,7 @@ const SET_LIST = 'https://raw.githubusercontent.com/SetProtocol/uniswap-tokenlis
const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json'
const WRAPPED_LIST = 'wrapped.tokensoft.eth'
const ROLL_LIST = 'https://app.tryroll.com/tokens.json'
const DHEDGE_LIST = 'https://list.dhedge.eth.link'
// const DHEDGE_LIST = 'https://list.dhedge.eth.link'
const SUSHI_LIST = 'https://token-list.sushi.com'
const CHAINLINK_LIST = 'https://token-list.sushi.com/chainlink'

Expand All @@ -27,18 +26,17 @@ const DEFAULT_LIST_OF_LISTS_TO_DISPLAY: string[] = [
CHAINLINK_LIST,
COMPOUND_LIST,
AAVE_LIST,
CMC_ALL_LIST,
// CMC_ALL_LIST,
COINGECKO_LIST,
UMA_LIST,
YEARN_LIST,
// UMA_LIST,
SYNTHETIX_LIST,
KLEROS_LIST,
GEMINI_LIST,
WRAPPED_LIST,
SET_LIST,
ROLL_LIST,
NFTX_LIST,
DHEDGE_LIST,
// DHEDGE_LIST,
]

export const DEFAULT_LIST_OF_LISTS: string[] = [
Expand All @@ -47,4 +45,4 @@ export const DEFAULT_LIST_OF_LISTS: string[] = [
]

// default lists to be 'active' aka searched across
export const DEFAULT_ACTIVE_LIST_URLS: string[] = [SUSHI_LIST, CHAINLINK_LIST, GEMINI_LIST, NFTX_LIST]
export const DEFAULT_ACTIVE_LIST_URLS: string[] = [SUSHI_LIST, CHAINLINK_LIST, NFTX_LIST]
30 changes: 30 additions & 0 deletions src/config/tokens/arbitrum-nova.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ChainId, Token } from '@sushiswap/core-sdk'

export const USDC = new Token(
ChainId.ARBITRUM_NOVA,
'0x750ba8b76187092B0D1E87E28daaf484d1b5273b',
6,
'USDC',
'USD Coin'
)
export const WBTC = new Token(
ChainId.ARBITRUM_NOVA,
'0x1d05e4e72cD994cdF976181CfB0707345763564d',
8,
'WBTC',
'Wrapped Bitcoin'
)
export const USDT = new Token(
ChainId.ARBITRUM_NOVA,
'0x52484E1ab2e2B22420a25c20FA49E173a26202Cd',
8,
'USDT',
'Tether USD'
)
export const DAI = new Token(
ChainId.ARBITRUM_NOVA,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai Stablecoin'
)
1 change: 1 addition & 0 deletions src/enums/ChainSubdomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export enum ChainSubdomain {
FUSE = 'fuse',
TELOS = 'telos',
MOONBEAM = 'moonbeam',
ARBITRUM_NOVA = 'arbitrum-nova',
}
19 changes: 13 additions & 6 deletions src/features/kashi/KashiMarketList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { t } from '@lingui/macro'
import { useLingui } from '@lingui/react'
import Dots from 'app/components/Dots'
import Search from 'app/components/Search'
import SortIcon from 'app/components/SortIcon'
import Typography from 'app/components/Typography'
Expand Down Expand Up @@ -141,12 +142,18 @@ const KashiMarketList: FC<KashiMarketList> = () => {
hasMore={numDisplayed <= items.length}
loader={null}
>
<>
{items.slice(0, numDisplayed).reduce<ReactNode[]>((acc, market, index) => {
if (market) acc.push(<KashiMarketListItem market={market} key={index} i18n={i18n} />)
return acc
}, [])}
</>
{items.length > 0 ? (
<>
{items.slice(0, numDisplayed).reduce<ReactNode[]>((acc, market, index) => {
if (market) acc.push(<KashiMarketListItem market={market} key={index} i18n={i18n} />)
return acc
}, [])}
</>
) : (
<div className="flex p-2 sm:justify-center">
<Dots>Loading</Dots>
</div>
)}
</InfiniteScroll>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/features/onsen/FarmList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const FarmList = ({ farms, term }) => {

const positionIds = positions.map((el) => el.id)

return items ? (
return items.length > 0 ? (
<>
<div className={classNames(TABLE_WRAPPER_DIV_CLASSNAME)}>
<div className="grid grid-cols-4 min-w-[768px]">
Expand Down
Loading

0 comments on commit 6806495

Please sign in to comment.