Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/sushi/src/chain/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ChainId = {
FLARE: 14,
MATCHAIN: 698,
BERA: 80094,
SONIC: 146,
} as const
export type ChainId = (typeof ChainId)[keyof typeof ChainId]

Expand Down Expand Up @@ -136,5 +137,6 @@ export const ChainKey = {
[ChainId.FLARE]: 'flare',
[ChainId.MATCHAIN]: 'matchain',
[ChainId.BERA]: 'berachain',
[ChainId.SONIC]: 'sonic',
} as const
export type ChainKey = (typeof ChainKey)[keyof typeof ChainKey]
18 changes: 18 additions & 0 deletions packages/sushi/src/chain/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,24 @@ export default [
name: 'Polygon Mainnet',
shortName: 'pol',
},
{
chainId: 146,
explorers: [
{
name: 'sonic',
url: 'https://explorer.soniclabs.com',
icon: 'sonic',
standard: 'none',
},
],
nativeCurrency: {
name: 'Sonic',
symbol: 'S',
decimals: 18,
},
name: 'Sonic Mainnet',
shortName: 'sonic',
},
{
chainId: 199,
explorers: [
Expand Down
18 changes: 17 additions & 1 deletion packages/sushi/src/config/bases-to-check-trades-against.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { ChainId } from '../chain/index.js'
import { MUSD, Token, USDB, USDe, cUSDX, sFLR } from '../currency/index.js'
import {
MUSD,
Token,
USDB,
USDe,
cUSDX,
sFLR,
scUSD,
} from '../currency/index.js'
import {
AAVE,
BUSD,
Expand Down Expand Up @@ -499,4 +507,12 @@ export const BASES_TO_CHECK_TRADES_AGAINST: {
USDC[ChainId.BERA],
USDe,
],
[ChainId.SONIC]: [
WNATIVE[ChainId.SONIC],
USDC[ChainId.SONIC],
USDT[ChainId.SONIC],
WETH9[ChainId.SONIC],
WBTC[ChainId.SONIC],
scUSD,
],
}
2 changes: 2 additions & 0 deletions packages/sushi/src/config/route-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export const ROUTE_PROCESSOR_4_SUPPORTED_CHAIN_IDS = [
ChainId.FLARE,
ChainId.MATCHAIN,
ChainId.BERA,
ChainId.SONIC,
] as const
export type RouteProcessor4ChainId =
(typeof ROUTE_PROCESSOR_4_SUPPORTED_CHAIN_IDS)[number]
Expand Down Expand Up @@ -340,6 +341,7 @@ export const ROUTE_PROCESSOR_4_ADDRESS: Record<
[ChainId.FLARE]: '0x4Aa9AEf59C7B63CD5C4B2eDE81F65A4225a99d9d',
[ChainId.MATCHAIN]: '0xbD8849759749B4d8506bC851aceF0E19F34EaBEE',
[ChainId.BERA]: '0x', // needs deployment
[ChainId.SONIC]: '0x', // needs deployment
} as const
export const isRouteProcessor4ChainId = (
chainId: ChainId,
Expand Down
37 changes: 37 additions & 0 deletions packages/sushi/src/config/viem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,37 @@ export const berachain = {
},
} as const

export const sonic = {
id: ChainId.SONIC,
name: 'Sonic Mainnet',
network: 'Sonic',
nativeCurrency: { name: 'Sonic', symbol: 'S', decimals: 18 },
rpcUrls: {
default: {
http: ['https://sonic.drpc.org'],
},
public: {
http: ['https://rpc.soniclabs.com'],
},
},
blockExplorers: {
etherscan: {
name: 'Sonic Explorer',
url: 'https://sonicscan.org',
},
default: {
name: 'Sonic Explorer',
url: 'https://sonicscan.org',
},
},
contracts: {
multicall3: {
address: '0xcA11bde05977b3631167028862bE2a173976CA11' as Address,
blockCreated: 60,
},
},
} as const

export const publicTransports: Record<ChainId, Transport> = {
[ChainId.ARBITRUM_NOVA]: http(arbitrumNova.rpcUrls.default.http[0]),
[ChainId.ARBITRUM]: http(arbitrum.rpcUrls.default.http[0]),
Expand Down Expand Up @@ -604,6 +635,7 @@ export const publicTransports: Record<ChainId, Transport> = {
[ChainId.BLAST]: http(blast.rpcUrls.default.http[0]),
[ChainId.FLARE]: http(flare.rpcUrls.default.http[0]),
[ChainId.BERA]: http(berachain.rpcUrls.default.http[0]),
[ChainId.SONIC]: http(sonic.rpcUrls.default.http[0]),
/* Testnets */ // TODO: add testnet transports
[ChainId.ARBITRUM_TESTNET]: http(arbitrumSepolia.rpcUrls.default.http[0]),
[ChainId.AVALANCHE_TESTNET]: http(avalancheFuji.rpcUrls.default.http[0]),
Expand Down Expand Up @@ -654,6 +686,7 @@ export const publicChains = [
flare as Chain,
matchain,
berachain,
sonic,

/* Testnets */
arbitrumSepolia as Chain,
Expand Down Expand Up @@ -837,6 +870,10 @@ export const publicClientConfig = {
chain: berachain as Chain,
transport: publicTransports[ChainId.BERA],
},
[ChainId.SONIC]: {
chain: sonic as Chain,
transport: publicTransports[ChainId.SONIC],
},

/* Testnets */
[ChainId.ARBITRUM_TESTNET]: {
Expand Down
6 changes: 6 additions & 0 deletions packages/sushi/src/currency/token-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const WBTC_ADDRESS = {
[ChainId.ZETACHAIN]: '0x13a0c5930c028511dc02665e7285134b6d11a5f4',
[ChainId.CRONOS]: '0x062E66477Faf219F25D27dCED647BF57C3107d52',
[ChainId.BERA]: '0x0555E30da8f98308EdB960aa94C0Db47230d2B9c',
[ChainId.SONIC]: '0x0555E30da8f98308EdB960aa94C0Db47230d2B9c',
} as const

export const UNI_ADDRESS = {
Expand Down Expand Up @@ -314,6 +315,7 @@ export const WETH9_ADDRESS = {
[ChainId.BLAST]: '0x4300000000000000000000000000000000000004',
[ChainId.FLARE]: '0x1502FA4be69d526124D453619276FacCab275d3D',
[ChainId.MATCHAIN]: '0xFF13A7A12fd485BC9687fF88D8Ae1A6b655Ab469',
[ChainId.SONIC]: '0x50c42dEAcD8Fc9773493ED674b675bE577f2634b',
} as const

export const WNATIVE_ADDRESS = {
Expand Down Expand Up @@ -373,6 +375,7 @@ export const WNATIVE_ADDRESS = {
[ChainId.FLARE]: '0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d',
[ChainId.MATCHAIN]: '0x4200000000000000000000000000000000000006',
[ChainId.BERA]: '0x6969696969696969696969696969696969696969',
[ChainId.SONIC]: '0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38',
} as const

export const SUSHI_ADDRESS = {
Expand Down Expand Up @@ -459,6 +462,7 @@ export const USDC_ADDRESS = {
[ChainId.FLARE]: '0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6',
[ChainId.MATCHAIN]: '0x97eec1c29f745dC7c267F90292AA663d997a601D',
[ChainId.BERA]: '0x549943e04f40284185054145c6E4e9568C1D3241',
[ChainId.SONIC]: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894',
} as const

export const USDT_ADDRESS = {
Expand Down Expand Up @@ -494,6 +498,7 @@ export const USDT_ADDRESS = {
[ChainId.ZETACHAIN]: '0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7',
[ChainId.FLARE]: '0x0B38e83B86d491735fEaa0a791F65c2B99535396',
[ChainId.MATCHAIN]: '0xB6dc6C8b71e88642cEAD3be1025565A9eE74d1C6',
[ChainId.SONIC]: '0x6047828dc181963ba44974801FF68e538dA5eaF9',
} as const

export const DAI_ADDRESS = {
Expand Down Expand Up @@ -548,6 +553,7 @@ export const FRAX_ADDRESS = {
[ChainId.BOBA]: '0xAb2AF3A98D229b7dAeD7305Bb88aD0BA2c42f9cA',
[ChainId.OPTIMISM]: '0x2E3D870790dC77A83DD1d18184Acc7439A53f475',
[ChainId.POLYGON_ZKEVM]: '0xFf8544feD5379D9ffa8D47a74cE6b91e632AC44D',
[ChainId.SONIC]: '0x80Eede496655FB9047dd39d9f418d5483ED600df',
} as const

export const FXS_ADDRESS = {
Expand Down
15 changes: 15 additions & 0 deletions packages/sushi/src/currency/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,13 @@ export const WNATIVE = {
symbol: 'WBERA',
name: 'Wrapped Bera',
}),
[ChainId.SONIC]: new Token({
chainId: ChainId.SONIC,
address: WNATIVE_ADDRESS[ChainId.SONIC],
decimals: 18,
symbol: 'WS',
name: 'Wrapped Sonic',
}),
} as const

export const SUSHI = addressMapToTokenMap(
Expand Down Expand Up @@ -1261,3 +1268,11 @@ export const weETH = new Token({
symbol: 'weETH',
name: 'Wrapped eETH',
})

export const scUSD = new Token({
chainId: ChainId.SONIC,
address: '0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE',
decimals: 6,
symbol: 'scUSD',
name: 'Sonic USD',
})
8 changes: 8 additions & 0 deletions packages/sushi/src/router/data-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import { QuickSwapV3Provider } from './liquidity-providers/QuickswapV3.js'
import { RingExchangeV2Provider } from './liquidity-providers/RingExchangeV2.js'
import { RingExchangeV3Provider } from './liquidity-providers/RingExchangeV3.js'
import { ScribeProvider } from './liquidity-providers/Scribe.js'
import { ShadowV2Provider } from './liquidity-providers/ShadowV2.js'
import { ShadowV3Provider } from './liquidity-providers/ShadowV3.js'
import { ShibaSwapProvider } from './liquidity-providers/ShibaSwap.js'
import { SolarbeamProvider } from './liquidity-providers/Solarbeam.js'
import { SparkDexV2Provider } from './liquidity-providers/SparkDexV2.js'
Expand All @@ -74,6 +76,8 @@ import { SquadSwapV2Provider } from './liquidity-providers/SquadSwapV2.js'
import { SushiSwapV2Provider } from './liquidity-providers/SushiSwapV2.js'
import { SushiSwapV3Provider } from './liquidity-providers/SushiSwapV3.js'
import { SwapBlastProvider } from './liquidity-providers/SwapBlast.js'
import { SwapxV2Provider } from './liquidity-providers/SwapXV2.js'
import { SwapxV3Provider } from './liquidity-providers/SwapXV3.js'
import { SwapsicleProvider } from './liquidity-providers/Swapsicle.js'
import {
ThrusterV2_1Provider,
Expand Down Expand Up @@ -243,6 +247,8 @@ export class DataFetcher {
RingExchangeV2Provider,
RingExchangeV3Provider,
ScribeProvider,
ShadowV2Provider,
ShadowV3Provider,
ShibaSwapProvider,
SolarbeamProvider,
SparkDexV2Provider,
Expand All @@ -255,6 +261,8 @@ export class DataFetcher {
SushiSwapV3Provider,
SwapBlastProvider,
SwapsicleProvider,
SwapxV2Provider,
SwapxV3Provider,
ThrusterV2_1Provider,
ThrusterV2_3Provider,
ThrusterV3Provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export enum LiquidityProviders {
NileV3 = 'NileV3',
KodiakV2 = 'KodiakV2',
KodiakV3 = 'KodiakV3',
ShadowV2 = 'ShadowV2',
ShadowV3 = 'ShadowV3',
SwapxV2 = 'SwapxV2',
SwapxV3 = 'SwapxV3',
}

export abstract class LiquidityProvider {
Expand Down Expand Up @@ -216,6 +220,8 @@ export const UniV2LiquidityProviders: LiquidityProviders[] = [
LiquidityProviders.MMFinance,
LiquidityProviders.KodiakV2,
LiquidityProviders.NileV2,
LiquidityProviders.SwapxV2,
LiquidityProviders.ShadowV2,
]

export const UniV3LiquidityProviders: LiquidityProviders[] = [
Expand Down Expand Up @@ -248,4 +254,6 @@ export const UniV3LiquidityProviders: LiquidityProviders[] = [
LiquidityProviders.VelodromeSlipstream,
LiquidityProviders.NileV3,
LiquidityProviders.KodiakV3,
LiquidityProviders.ShadowV3,
LiquidityProviders.SwapxV3,
]
Loading