From e89307752c29c8da81884adb15367fdbe8a8d180 Mon Sep 17 00:00:00 2001 From: Nguyen Van Viet Date: Mon, 6 May 2024 17:06:26 +0700 Subject: [PATCH] feat: chain expansion - xlayer (#2488) --- package.json | 4 +- src/components/ClassicElasticTab.tsx | 1 + .../Header/web3/NetworkModal/index.tsx | 2 - src/constants/bases.ts | 1 + src/constants/networks.ts | 3 ++ src/constants/networks/index.ts | 2 +- src/constants/networks/{x1.ts => xlayer.ts} | 37 ++++++++++--------- src/constants/tokens.ts | 7 +++- src/pages/About/AboutKyberSwap/index.tsx | 5 +++ yarn.lock | 8 ++-- 10 files changed, 42 insertions(+), 28 deletions(-) rename src/constants/networks/{x1.ts => xlayer.ts} (76%) diff --git a/package.json b/package.json index 0cd12a2e23..158618284e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@holdstation/paymaster-helper": "^2.0.20", "@kyberswap/krystal-walletconnect-v2": "0.0.1", "@kyberswap/ks-sdk-classic": "^1.0.3", - "@kyberswap/ks-sdk-core": "1.1.3", + "@kyberswap/ks-sdk-core": "1.1.5", "@kyberswap/ks-sdk-elastic": "^1.1.2", "@kyberswap/oauth2": "1.0.2", "@lingui/macro": "^4.6.0", @@ -210,7 +210,7 @@ "vite-tsconfig-paths": "^4.0.8" }, "resolutions": { - "@kyberswap/ks-sdk-core": "1.1.3", + "@kyberswap/ks-sdk-core": "1.1.5", "babel-plugin-lodash/@babel/types": "~7.20.0", "react-error-overlay": "6.0.9" } diff --git a/src/components/ClassicElasticTab.tsx b/src/components/ClassicElasticTab.tsx index d3ba51f46f..3f0546fe29 100644 --- a/src/components/ClassicElasticTab.tsx +++ b/src/components/ClassicElasticTab.tsx @@ -54,6 +54,7 @@ function ClassicElasticTab() { ChainId.SCROLL, ChainId.BLAST, ChainId.MANTLE, + ChainId.XLAYER, ].includes(chainId) const showLegacyExplicit = diff --git a/src/components/Header/web3/NetworkModal/index.tsx b/src/components/Header/web3/NetworkModal/index.tsx index 4e35807d14..55829fd108 100644 --- a/src/components/Header/web3/NetworkModal/index.tsx +++ b/src/components/Header/web3/NetworkModal/index.tsx @@ -10,7 +10,6 @@ import { ButtonAction } from 'components/Button' import Column from 'components/Column' import Modal from 'components/Modal' import Row, { RowBetween } from 'components/Row' -import { x1 } from 'constants/networks/index' import { NetworkInfo } from 'constants/networks/type' import { Z_INDEXS } from 'constants/styles' import { useActiveWeb3React } from 'hooks' @@ -204,7 +203,6 @@ export default function NetworkModal({ .map((networkInfo: NetworkInfo) => { return renderNetworkButton(networkInfo) })} - )} diff --git a/src/constants/bases.ts b/src/constants/bases.ts index ef2e3cbdb5..34cd2e88b9 100644 --- a/src/constants/bases.ts +++ b/src/constants/bases.ts @@ -27,6 +27,7 @@ const WETH_ONLY: ChainTokenList = { [ChainId.SCROLL]: [WETH[ChainId.SCROLL]], [ChainId.BLAST]: [WETH[ChainId.BLAST]], [ChainId.MANTLE]: [WETH[ChainId.MANTLE]], + [ChainId.XLAYER]: [WETH[ChainId.XLAYER]], } // used to construct intermediary pairs for trading diff --git a/src/constants/networks.ts b/src/constants/networks.ts index c35716b672..58dd95e601 100644 --- a/src/constants/networks.ts +++ b/src/constants/networks.ts @@ -20,6 +20,7 @@ import { mumbai, optimism, scroll, + xlayer, zkEvm, zksync, } from './networks/index' @@ -48,6 +49,7 @@ const NETWORKS_INFO_CONFIG: NETWORKS_INFO_CONFIG_TYPE = { [ChainId.SCROLL]: scroll, [ChainId.BLAST]: blast, [ChainId.MANTLE]: mantle, + [ChainId.XLAYER]: xlayer, } as const //this Proxy helps fallback undefined ChainId by Ethereum info @@ -78,6 +80,7 @@ export const MAINNET_NETWORKS = [ ChainId.CRONOS, ChainId.BLAST, ChainId.MANTLE, + ChainId.XLAYER, ] as const // These option of walletconnect is not support by wallets properly diff --git a/src/constants/networks/index.ts b/src/constants/networks/index.ts index 17f488c995..e66e43792a 100644 --- a/src/constants/networks/index.ts +++ b/src/constants/networks/index.ts @@ -17,5 +17,5 @@ export { default as zkEvm } from './zkevm' export { default as base } from './base' export { default as scroll } from './scroll' export { default as blast } from './blast' -export { default as x1 } from './x1' +export { default as xlayer } from './xlayer' export { default as mantle } from './mantle' diff --git a/src/constants/networks/x1.ts b/src/constants/networks/xlayer.ts similarity index 76% rename from src/constants/networks/x1.ts rename to src/constants/networks/xlayer.ts index 22e08f35f3..1e657c4ac0 100644 --- a/src/constants/networks/x1.ts +++ b/src/constants/networks/xlayer.ts @@ -1,4 +1,5 @@ -import EthereumLogo from 'assets/images/ethereum-logo.png' +import { ChainId } from '@kyberswap/ks-sdk-core' + import { NetworkInfo } from 'constants/networks/type' const EMPTY = '' @@ -6,29 +7,29 @@ const EMPTY_ARRAY: any[] = [] const NOT_SUPPORT = null const x1: NetworkInfo = { - chainId: 196, - route: 'x1', - ksSettingRoute: 'x1', - priceRoute: 'x1', - poolFarmRoute: 'x1', - aggregatorRoute: 'x1', - name: 'Okx X1', + chainId: ChainId.XLAYER, + route: 'xlayer', + ksSettingRoute: 'xlayer', + priceRoute: 'xlayer', + poolFarmRoute: 'xlayer', + aggregatorRoute: 'xlayer', + name: 'X Layer', icon: 'https://storage.googleapis.com/ks-setting-1d682dca/bafc6027-7c84-4517-8fbd-f18fda18c5b91709787884512.png', iconSelected: NOT_SUPPORT, defaultBlockSubgraph: '', - etherscanUrl: '', - etherscanName: 'Okx X1 Scan', - bridgeURL: 'https://www.okx.com/x1/bridge', + etherscanUrl: 'https://www.okx.com/explorer/xlayer', + etherscanName: 'X Layer Explorer', + bridgeURL: 'https://www.okx.com/xlayer/bridge', nativeToken: { - symbol: 'ETH', - name: 'ETH', - logo: EthereumLogo, + symbol: 'OKB', + name: 'OKB', + logo: 'https://s2.coinmarketcap.com/static/img/coins/64x64/3897.png', decimal: 18, minForGas: 10 ** 16, }, - defaultRpcUrl: '', + defaultRpcUrl: 'https://rpc.xlayer.tech', multicall: '0xcA11bde05977b3631167028862bE2a173976CA11', classic: { defaultSubgraph: '', @@ -64,10 +65,10 @@ const x1: NetworkInfo = { helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B', }, }, - limitOrder: NOT_SUPPORT, + limitOrder: '*', averageBlockTimeInSeconds: 2.0, // dont use for base - coingeckoNetworkId: 'blast', - coingeckoNativeTokenId: 'ethereum', + coingeckoNetworkId: 'xlayer', + coingeckoNativeTokenId: 'okb', deBankSlug: EMPTY, dexToCompare: NOT_SUPPORT, geckoTermialId: NOT_SUPPORT, diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index 162f07201b..1b50e37d28 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -54,6 +54,7 @@ export const STABLE_COIN_ADDRESSES_TO_TAKE_FEE: Record = { [ChainId.SCROLL]: [], [ChainId.BLAST]: [], [ChainId.MANTLE]: [], + [ChainId.XLAYER]: [], } // This is basically the same as STABLE_COIN_ADDRESSES_TO_TAKE_FEE, @@ -141,6 +142,7 @@ export const SUPER_STABLE_COINS_ADDRESS: { [chainId in ChainId]: string[] } = { [ChainId.SCROLL]: [], [ChainId.BLAST]: [], [ChainId.MANTLE]: [], + [ChainId.XLAYER]: [], } export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = { @@ -190,6 +192,7 @@ export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = { [ChainId.SCROLL]: [], [ChainId.BLAST]: [], [ChainId.MANTLE]: [], + [ChainId.XLAYER]: [], } export const KNC_ADDRESS = '0xdeFA4e8a7bcBA345F687a2f1456F5Edd9CE97202' @@ -217,6 +220,7 @@ export const KNC: { [chainId in ChainId]: Token } = { [ChainId.ZKSYNC]: new Token(ChainId.ZKSYNC, KNC_ADDRESS, 18, 'KNC', 'KNC'), [ChainId.BLAST]: new Token(ChainId.BLAST, KNC_ADDRESS, 18, 'KNC', 'KNC'), [ChainId.MANTLE]: new Token(ChainId.MANTLE, KNC_ADDRESS, 18, 'KNC', 'KNC'), + [ChainId.XLAYER]: new Token(ChainId.MANTLE, KNC_ADDRESS, 18, 'KNC', 'KNC'), [ChainId.AVAXTESTNET]: new Token(ChainId.AVAXTESTNET, KNC_ADDRESS, 18, 'KNC', 'KNC'), [ChainId.MUMBAI]: new Token(ChainId.MUMBAI, '0xFD1f9381Cb641Dc76Fe8087dbcf8ea84a2c77cbE', 18, 'KNC', 'KNC'), @@ -245,7 +249,8 @@ export const DEFAULT_OUTPUT_TOKEN_BY_CHAIN: Partial> = { [ChainId.BASE]: new Token(ChainId.BASE, '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA', 6, 'USDC', 'USD Coin'), [ChainId.SCROLL]: new Token(ChainId.SCROLL, '0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df', 6, 'USDT', 'Tether USD'), [ChainId.BLAST]: new Token(ChainId.BLAST, '0x4300000000000000000000000000000000000003', 18, 'USDB', 'USDB'), - [ChainId.MANTLE]: new Token(ChainId.MANTLE, '0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE', 18, 'USDT', 'USDT'), + [ChainId.MANTLE]: new Token(ChainId.MANTLE, '0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE', 6, 'USDT', 'USDT'), + [ChainId.XLAYER]: new Token(ChainId.XLAYER, '0x1e4a5963abfd975d8c9021ce480b42188849d41d', 6, 'USDT', 'USDT'), } export const DEFAULT_SWAP_FEE_STABLE_PAIRS = 4 diff --git a/src/pages/About/AboutKyberSwap/index.tsx b/src/pages/About/AboutKyberSwap/index.tsx index 28cb81c492..3eb9bc130f 100644 --- a/src/pages/About/AboutKyberSwap/index.tsx +++ b/src/pages/About/AboutKyberSwap/index.tsx @@ -366,6 +366,11 @@ function AboutKyberSwap() { Blast mantle + + + X Layer + X Layer + diff --git a/yarn.lock b/yarn.lock index 20697d2009..490c2c2b6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3726,10 +3726,10 @@ tiny-warning "^1.0.3" toformat "^2.0.0" -"@kyberswap/ks-sdk-core@1.1.3", "@kyberswap/ks-sdk-core@^1.0.5": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@kyberswap/ks-sdk-core/-/ks-sdk-core-1.1.3.tgz#952dabacff1a831463b0dd95f8cdbe13bfc41c4f" - integrity sha512-TzTkhBVqlIXUi3s20MiTakdEcpyvMd/3JG0B3Xo/AWMFqc8WSaMRn3/mr4cMX5UXeo1LNy0nLIRD06bjQGyHjw== +"@kyberswap/ks-sdk-core@1.1.5", "@kyberswap/ks-sdk-core@^1.0.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@kyberswap/ks-sdk-core/-/ks-sdk-core-1.1.5.tgz#d742b494e55d53e1c85db9c28dac32741268ba1e" + integrity sha512-bMLtGopqjratn0TWSNMh8qtcotWyE4Ek8rL4DB8J0OZnv3y79QlGq4lhKGAHPmx35GWZomlw2RDrctqHlvORaQ== dependencies: "@ethersproject/address" "^5.0.2" big.js "^5.2.2"