Skip to content

Commit

Permalink
feat: chain expansion - xlayer (#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv authored May 6, 2024
1 parent 1272b5b commit e893077
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions src/components/ClassicElasticTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function ClassicElasticTab() {
ChainId.SCROLL,
ChainId.BLAST,
ChainId.MANTLE,
ChainId.XLAYER,
].includes(chainId)

const showLegacyExplicit =
Expand Down
2 changes: 0 additions & 2 deletions src/components/Header/web3/NetworkModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -204,7 +203,6 @@ export default function NetworkModal({
.map((networkInfo: NetworkInfo) => {
return renderNetworkButton(networkInfo)
})}
<DraggableNetworkButton networkInfo={x1} isComingSoon />
</>
</NetworkList>
)}
Expand Down
1 change: 1 addition & 0 deletions src/constants/bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
mumbai,
optimism,
scroll,
xlayer,
zkEvm,
zksync,
} from './networks/index'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/constants/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
37 changes: 19 additions & 18 deletions src/constants/networks/x1.ts → src/constants/networks/xlayer.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import EthereumLogo from 'assets/images/ethereum-logo.png'
import { ChainId } from '@kyberswap/ks-sdk-core'

import { NetworkInfo } from 'constants/networks/type'

const EMPTY = ''
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: '',
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const STABLE_COIN_ADDRESSES_TO_TAKE_FEE: Record<ChainId, string[]> = {
[ChainId.SCROLL]: [],
[ChainId.BLAST]: [],
[ChainId.MANTLE]: [],
[ChainId.XLAYER]: [],
}

// This is basically the same as STABLE_COIN_ADDRESSES_TO_TAKE_FEE,
Expand Down Expand Up @@ -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[][] } = {
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -245,7 +249,8 @@ export const DEFAULT_OUTPUT_TOKEN_BY_CHAIN: Partial<Record<ChainId, Token>> = {
[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
Expand Down
5 changes: 5 additions & 0 deletions src/pages/About/AboutKyberSwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ function AboutKyberSwap() {
<img src="https://i.imgur.com/kG2lDVA.png" alt="Blast" width="100%" />

<img src="https://www.mantle.xyz/logo-lockup.svg" alt="mantle" width="100%" />

<Flex alignItems="center" sx={{ minWidth: '190px', gap: '6px' }}>
<img src="https://static.okx.com/cdn/assets/imgs/243/230501A8E74482AB.png" alt="X Layer" width="50px" />
<Text>X Layer</Text>
</Flex>
</Powered>
</Text>
</Wrapper>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e893077

Please sign in to comment.