Skip to content

Commit

Permalink
feat(EX-2848): add bera chain
Browse files Browse the repository at this point in the history
* feat: add bera chain

* fix: logo
  • Loading branch information
viet-nv authored Feb 13, 2025
1 parent 5b4f788 commit ad94259
Show file tree
Hide file tree
Showing 30 changed files with 252 additions and 175 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@holdstation/paymaster-helper": "^2.0.20",
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.1.7",
"@kyberswap/ks-sdk-core": "1.1.8",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/liquidity-widgets": "1.1.11",
"@kyberswap/zap-migration-widgets": "1.0.7",
Expand Down Expand Up @@ -119,9 +119,9 @@
"swiper": "^8.4.4",
"ua-parser-js": "^1.0.33",
"util": "^0.12.5",
"viem": "^2.21.55",
"viem": "^2.23.1",
"vite-plugin-env-compatible": "^1.1.1",
"wagmi": "^2.12.25",
"wagmi": "^2.14.11",
"walktour": "^5.2.0",
"wcag-contrast": "^3.0.0",
"workbox-core": "^6.5.4",
Expand Down Expand Up @@ -199,7 +199,7 @@
"vite-tsconfig-paths": "^4.0.8"
},
"resolutions": {
"@kyberswap/ks-sdk-core": "1.1.7",
"@kyberswap/ks-sdk-core": "1.1.8",
"babel-plugin-lodash/@babel/types": "~7.20.0",
"react-error-overlay": "6.0.9"
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Web3Provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
arbitrum,
avalanche,
base,
berachain,
blast,
bsc,
fantom,
Expand Down Expand Up @@ -159,6 +160,7 @@ export const wagmiConfig = createConfig({
fantom,
blast,
sonic,
berachain,
],
connectors: [
injectedWithFallback(),
Expand Down
8 changes: 2 additions & 6 deletions src/components/swapv2/LimitOrder/OrderBook/OrderItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Flex, Text } from 'rebass'
import styled, { CSSProperties } from 'styled-components'

import CurrencyLogo from 'components/CurrencyLogo'
import useChainsConfig from 'hooks/useChainsConfig'
import { NETWORKS_INFO } from 'hooks/useChainsConfig'
import useTheme from 'hooks/useTheme'
import { useLimitState } from 'state/limit/hooks'
import { MEDIA_WIDTHS } from 'theme'
Expand Down Expand Up @@ -66,12 +66,8 @@ export default function OrderItem({
const theme = useTheme()
const upToExtraSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToExtraSmall}px)`)
const { currencyIn: makerCurrency, currencyOut: takerCurrency } = useLimitState()
const { supportedChains } = useChainsConfig()

const chain = useMemo(
() => supportedChains.find(chain => chain.chainId === order.chainId),
[order.chainId, supportedChains],
)
const chain = useMemo(() => NETWORKS_INFO[order.chainId], [order.chainId])

return (
<ItemWrapper style={style}>
Expand Down
1 change: 1 addition & 0 deletions src/constants/bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const WETH_ONLY: ChainTokenList = {
[ChainId.BLAST]: [WETH[ChainId.BLAST]],
[ChainId.MANTLE]: [WETH[ChainId.MANTLE]],
[ChainId.SONIC]: [WETH[ChainId.SONIC]],
[ChainId.BERA]: [WETH[ChainId.BERA]],
}

// 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 @@ -6,6 +6,7 @@ import {
avax,
avaxTestnet,
base,
bera,
blast,
bnb,
bnbTestnet,
Expand Down Expand Up @@ -46,6 +47,7 @@ const NETWORKS_INFO_CONFIG: NETWORKS_INFO_CONFIG_TYPE = {
[ChainId.BLAST]: blast,
[ChainId.MANTLE]: mantle,
[ChainId.SONIC]: sonic,
[ChainId.BERA]: bera,
} as const

//this Proxy helps fallback undefined ChainId by Ethereum info
Expand Down Expand Up @@ -75,6 +77,7 @@ export const MAINNET_NETWORKS = [
ChainId.BLAST,
ChainId.MANTLE,
ChainId.SONIC,
ChainId.BERA,
] as const

// These option of walletconnect is not support by wallets properly
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const arbitrumInfo: NetworkInfo = {
route: 'arbitrum',
ksSettingRoute: 'arbitrum',
priceRoute: 'arbitrum',
poolFarmRoute: 'arbitrum',
aggregatorRoute: 'arbitrum',
name: 'Arbitrum',
icon: arbitrumIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/avax-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const avaxTestnetInfo: NetworkInfo = {
ksSettingRoute: 'avalanche',
priceRoute: 'avalanche',
aggregatorRoute: 'avalanche',
poolFarmRoute: EMPTY,
name: 'Avalanche Testnet',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/e72081b5-cb5f-4fb6-b771-ac189bdfd7c81699420213175.png',

Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/avax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const avaxInfo: NetworkInfo = {
route: 'avalanche',
ksSettingRoute: 'avalanche',
priceRoute: 'avalanche',
poolFarmRoute: 'avalanche',
aggregatorRoute: 'avalanche',
name: 'Avalanche',
icon: avalancheIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const base: NetworkInfo = {
route: 'base',
ksSettingRoute: 'base',
priceRoute: 'base',
poolFarmRoute: 'base',
aggregatorRoute: 'base',
name: 'Base',
icon: 'https://raw.githubusercontent.com/base-org/brand-kit/001c0e9b40a67799ebe0418671ac4e02a0c683ce/logo/in-product/Base_Network_Logo.svg',
Expand Down
74 changes: 74 additions & 0 deletions src/constants/networks/bera.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { ChainId } from '@kyberswap/ks-sdk-core'

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

const EMPTY_ARRAY: any[] = []
const NOT_SUPPORT = null

const bera: NetworkInfo = {
chainId: ChainId.BERA,
route: 'berachain',
ksSettingRoute: 'berachain',
priceRoute: 'berachain',
aggregatorRoute: 'berachain',
name: 'Berachain',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/68e11813-067b-42d7-8d7a-c1b7bf80714e1739239376230.png',

iconSelected: NOT_SUPPORT,

defaultBlockSubgraph: '',
etherscanUrl: 'https://berascan.com',
etherscanName: 'Berascan',
bridgeURL: 'https://bridge.berachain.com/bridge/token',
nativeToken: {
symbol: 'BERA',
name: 'BERA',
logo: 'https://storage.googleapis.com/ks-setting-1d682dca/68e11813-067b-42d7-8d7a-c1b7bf80714e1739239376230.png',
decimal: 18,
minForGas: 2 * 10 ** 17,
},
defaultRpcUrl: 'https://rpc.berachain.com',
multicall: '0xcA11bde05977b3631167028862bE2a173976CA11',
classic: {
defaultSubgraph: '',
static: {
zap: '',
router: '',
factory: '',
},
oldStatic: NOT_SUPPORT,
dynamic: NOT_SUPPORT,
claimReward: NOT_SUPPORT,
fairlaunch: EMPTY_ARRAY,
fairlaunchV2: EMPTY_ARRAY,
fairlaunchV3: EMPTY_ARRAY,
},
elastic: {
defaultSubgraph: 'https://scroll-graph.kyberengineering.io/subgraphs/name/kybernetwork/kyberswap-elastic-scroll',
startBlock: 36376,
coreFactory: '0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A',
nonfungiblePositionManager: '0xe222fBE074A436145b255442D919E4E3A6c6a480',
tickReader: '0x8Fd8Cb948965d9305999D767A02bf79833EADbB3',
initCodeHash: '0x00e263aaa3a2c06a89b53217a9e7aad7e15613490a72e0f95f303c4de2dc7045',
quoter: '0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856',
routers: '0xF9c2b5746c946EF883ab2660BbbB1f10A5bdeAb4',
farms: ['0x7D5ba536ab244aAA1EA42aB88428847F25E3E676'],
farmv2Quoter: '0x6AFeb9EDd6Cf44fA8E89b1eee28284e6dD7705C8',
farmV2S: [],
'farmV2.1S': ['0x3D6AfE2fB73fFEd2E3dD00c501A174554e147a43', '0xf2BcDf38baA52F6b0C1Db5B025DfFf01Ae1d6dBd'],
zap: {
router: '0x30C5322E4e08AD500c348007f92f120ab4E2b79e',
validator: '0xf0096e5B4AAfeEA1DF557264091569ba125c1172',
executor: '0x8ac7895130e3be8654fff544ae20bf2a93ef19d1',
helper: '0x214061F0e250A27a49f609d9caf2987a7bC8fA6B',
},
},
limitOrder: '*',
averageBlockTimeInSeconds: 2.0, // dont use for base
coingeckoNetworkId: 'bera',
coingeckoNativeTokenId: 'bera',
dexToCompare: NOT_SUPPORT,
geckoTermialId: NOT_SUPPORT,
}

export default bera
1 change: 0 additions & 1 deletion src/constants/networks/blast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const scroll: NetworkInfo = {
route: 'blast',
ksSettingRoute: 'blast',
priceRoute: 'blast',
poolFarmRoute: 'blast',
aggregatorRoute: 'blast',
name: 'Blast',
icon: 'https://static.debank.com/image/project/logo_url/blast/c0e1eb5f4051bd62ca904cf2e3282f47.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/bnb-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const bnbTestnetInfo: NetworkInfo = {
route: 'bnb-testnet',
ksSettingRoute: 'bsc',
priceRoute: 'bsc',
poolFarmRoute: EMPTY,
aggregatorRoute: 'bsc',
name: 'BNB Testnet',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/14c1b7c4-b66e-4169-b82e-ea6237f15b461699420601184.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/bnb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const bnbInfo: NetworkInfo = {
route: 'bnb',
ksSettingRoute: 'bsc',
priceRoute: 'bsc',
poolFarmRoute: 'bsc',
aggregatorRoute: 'bsc',
name: 'BNB Chain',
icon: bnbIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ethereumInfo: NetworkInfo = {
route: 'ethereum',
ksSettingRoute: 'ethereum',
priceRoute: 'ethereum',
poolFarmRoute: 'ethereum',
aggregatorRoute: 'ethereum',
name: 'Ethereum',
icon: ethereumIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const fantomInfo: NetworkInfo = {
route: 'fantom',
ksSettingRoute: 'fantom',
priceRoute: 'fantom',
poolFarmRoute: 'fantom',
aggregatorRoute: 'fantom',
name: 'Fantom',
icon: fantomIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/görli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const görliInfo: NetworkInfo = {
route: 'goerli',
ksSettingRoute: 'ethereum',
priceRoute: 'ethereum',
poolFarmRoute: EMPTY,
aggregatorRoute: EMPTY,
name: 'Görli',
icon: ethereumIcon,
Expand Down
1 change: 1 addition & 0 deletions src/constants/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export { default as scroll } from './scroll'
export { default as blast } from './blast'
export { default as sonic } from './sonic'
export { default as mantle } from './mantle'
export { default as bera } from './bera'
1 change: 0 additions & 1 deletion src/constants/networks/linea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const lineaInfo: NetworkInfo = {
route: 'linea',
ksSettingRoute: 'linea',
priceRoute: 'linea',
poolFarmRoute: 'linea',
aggregatorRoute: 'linea',
name: 'Linea',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/12a257d3-65e3-4b16-8a84-03a4ca34a6bc1693378197244.svg',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/mantle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const mantle: NetworkInfo = {
route: 'mantle',
ksSettingRoute: 'mantle',
priceRoute: 'mantle',
poolFarmRoute: 'mantle',
aggregatorRoute: 'mantle',
name: 'Mantle',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/2bccd96f-b100-4ca1-858e-d8353ab0d0861710387147471.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/matic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const maticInfo: NetworkInfo = {
route: 'polygon',
ksSettingRoute: 'polygon',
priceRoute: 'polygon',
poolFarmRoute: 'polygon',
aggregatorRoute: 'polygon',
name: 'Polygon PoS',
icon: polygonIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/mumbai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const mumbaiInfo: NetworkInfo = {
route: 'mumbai',
ksSettingRoute: 'mumbai',
priceRoute: 'mumbai',
poolFarmRoute: EMPTY,
aggregatorRoute: 'mumbai',
name: 'Mumbai',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/8a936cf9-3e8f-4518-9fb2-8579c14fb8cd1699420035633.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const optimismInfo: NetworkInfo = {
route: 'optimism',
ksSettingRoute: 'optimism',
priceRoute: 'optimism',
poolFarmRoute: 'optimism',
aggregatorRoute: 'optimism',
name: 'Optimism',
icon: optimismIcon,
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const scroll: NetworkInfo = {
route: 'scroll',
ksSettingRoute: 'scroll',
priceRoute: 'scroll',
poolFarmRoute: 'scroll',
aggregatorRoute: 'scroll',
name: 'Scroll',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/fe12013c-4d72-4ac3-9415-a278b7d474c71697595633825.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/sonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const sonic: NetworkInfo = {
route: 'sonic',
ksSettingRoute: 'sonic',
priceRoute: 'sonic',
poolFarmRoute: 'sonic',
aggregatorRoute: 'sonic',
name: 'Sonic',
icon: 'https://www.soniclabs.com/favicon.ico',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface NetworkInfo {

readonly geckoTermialId: string | null
readonly state?: ChainState
readonly poolFarmRoute: string // use this to get data from our internal BE
readonly defaultBlockSubgraph: string
readonly multicall: string
readonly classic: {
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/zkevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const zkEvm: NetworkInfo = {
route: 'polygon-zkevm',
ksSettingRoute: 'polygon-zkevm',
priceRoute: 'polygon-zkevm',
poolFarmRoute: 'polygon-zkevm',
aggregatorRoute: 'polygon-zkevm',
name: 'Polygon zkEVM',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/815d1f9c-86b2-4515-8bb1-4212106321c01699420293856.png',
Expand Down
1 change: 0 additions & 1 deletion src/constants/networks/zksync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const zkSyncInfo: NetworkInfo = {
route: 'zksync',
ksSettingRoute: 'zksync',
priceRoute: 'zksync',
poolFarmRoute: 'zksync',
aggregatorRoute: 'zksync',
name: 'zkSync Era',
icon: 'https://storage.googleapis.com/ks-setting-1d682dca/bd11850b-6aef-48c6-a27d-f8ee833e0dbc1693378187666.svg',
Expand Down
5 changes: 5 additions & 0 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const STABLE_COIN_ADDRESSES_TO_TAKE_FEE: Record<ChainId, string[]> = {
[ChainId.BLAST]: [],
[ChainId.MANTLE]: [],
[ChainId.SONIC]: [],
[ChainId.BERA]: [],
}

// This is basically the same as STABLE_COIN_ADDRESSES_TO_TAKE_FEE,
Expand Down Expand Up @@ -118,6 +119,7 @@ export const SUPER_STABLE_COINS_ADDRESS: { [chainId in ChainId]: string[] } = {
[ChainId.BLAST]: [],
[ChainId.MANTLE]: [],
[ChainId.SONIC]: [],
[ChainId.BERA]: [],
}

export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = {
Expand Down Expand Up @@ -390,6 +392,7 @@ export const CORRELATED_COINS_ADDRESS: { [chainId in ChainId]: string[][] } = {
[ChainId.BLAST]: [],
[ChainId.MANTLE]: [],
[ChainId.SONIC]: [],
[ChainId.BERA]: [],
}

export const KNC_ADDRESS = '0xdeFA4e8a7bcBA345F687a2f1456F5Edd9CE97202'
Expand All @@ -416,6 +419,7 @@ export const KNC: { [chainId in ChainId]: Token } = {
[ChainId.BLAST]: new Token(ChainId.BLAST, KNC_ADDRESS, 18, 'KNC', 'KNC'),
[ChainId.MANTLE]: new Token(ChainId.MANTLE, KNC_ADDRESS, 18, 'KNC', 'KNC'),
[ChainId.SONIC]: new Token(ChainId.SONIC, KNC_ADDRESS, 18, 'KNC', 'KNC'),
[ChainId.BERA]: new Token(ChainId.BERA, 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 @@ -444,6 +448,7 @@ export const DEFAULT_OUTPUT_TOKEN_BY_CHAIN: Partial<Record<ChainId, Token>> = {
[ChainId.BLAST]: new Token(ChainId.BLAST, '0x4300000000000000000000000000000000000003', 18, 'USDB', 'USDB'),
[ChainId.MANTLE]: new Token(ChainId.MANTLE, '0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE', 6, 'USDT', 'USDT'),
[ChainId.SONIC]: new Token(ChainId.SONIC, '0x29219dd400f2Bf60E5a23d13Be72B486D4038894', 6, 'USDC.e', 'USDC.e'),
[ChainId.BERA]: new Token(ChainId.BERA, '0x549943e04f40284185054145c6E4e9568C1D3241', 6, 'USDC.e', 'USDC.e'),
}

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 @@ -358,6 +358,11 @@ function AboutKyberSwap() {
<img src="https://www.mantle.xyz/logo-lockup.svg" alt="mantle" width="100%" />

<img src="https://www.soniclabs.com/sonic-logo.svg" alt="Sonic" width="100%" />

<Flex sx={{ gap: '12px' }} alignItems="center">
<img src="https://www.berachain.com/images/icons/berachain.svg" alt="Bera" width="80px" />
<Text>Berachain</Text>
</Flex>
</Powered>
</Text>
</Wrapper>
Expand Down
Loading

0 comments on commit ad94259

Please sign in to comment.