Skip to content

Commit aab662c

Browse files
committed
update sonic config
1 parent 9fdcfbf commit aab662c

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

src/common/utils/viemClients.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,39 @@ export const bartio = defineChain({
3232
},
3333
})
3434

35+
const sonicnetwork = defineChain({
36+
id: 146,
37+
name: "Sonic",
38+
nativeCurrency: {
39+
decimals: 18,
40+
name: "Sonic",
41+
symbol: "S",
42+
},
43+
rpcUrls: {
44+
default: {
45+
http: ["https://rpc.soniclabs.com"],
46+
webSocket: ["wss://sonic-rpc.publicnode.com"],
47+
},
48+
},
49+
blockExplorers: {
50+
default: { name: "Explorer", url: "https://sonicscan.org" },
51+
},
52+
contracts: {
53+
multicall3: {
54+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
55+
blockCreated: 1,
56+
},
57+
},
58+
})
59+
3560
export const RPC_URLS: Record<number, string> = {
3661
[chains.mainnet.id]: process.env.RPC_URL_1 || "",
3762
[chains.sepolia.id]: process.env.RPC_URL_11155111 || "",
3863
[chains.arbitrum.id]: process.env.RPC_URL_42161 || "",
3964
[chains.base.id]: process.env.RPC_URL_8453 || "",
4065
[bartio.id]: process.env.RPC_URL_80084 || "",
4166
[80094]: process.env.RPC_URL_80094 || "",
67+
[146]: process.env.RPC_URL_146 || "",
4268
[chains.foundry.id]: process.env.RPC_URL_31337 || "http://localhost:8545",
4369
} as const
4470

@@ -67,6 +93,10 @@ export const createClients = (): Record<number, Client<Transport, Chain>> => ({
6793
transport: http(RPC_URLS[chains.foundry.id]),
6894
}),
6995
[chains.arbitrum.id]: createChainConfig(chains.arbitrum),
96+
[sonicnetwork.id]: createClient({
97+
chain: sonicnetwork,
98+
transport: http(RPC_URLS[sonicnetwork.id]),
99+
}),
70100
})
71101

72102
export const viemClients = createClients()

src/swapService/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import beraRoutingConfig from "./bera"
55
import bobRoutingConfig from "./bob"
66
import defaultRoutingConfig from "./default"
77
import mainnetRoutingConfig from "./mainnet"
8+
import sonicRoutingConfig from "./sonic"
89
import swellRoutingConfig from "./swell"
910

1011
const routingConfig: RoutingConfig = {
@@ -13,6 +14,7 @@ const routingConfig: RoutingConfig = {
1314
[1923]: swellRoutingConfig,
1415
[80094]: beraRoutingConfig,
1516
[60808]: bobRoutingConfig,
17+
[146]: sonicRoutingConfig,
1618
}
1719

1820
export const getRoutingConfig = (chainId: number) => {

src/swapService/config/sonic.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { type ChainRoutingConfig, SwapperMode } from "../interface"
2+
import {
3+
StrategyBalmySDK,
4+
StrategyERC4626Wrapper,
5+
StrategyRepayWrapper,
6+
} from "../strategies"
7+
const WSTKSCUSD_SONIC = "0x9fb76f7ce5FCeAA2C42887ff441D46095E494206"
8+
const WSTKSCETH_SONIC = "0xE8a41c62BB4d5863C6eadC96792cFE90A1f37C47"
9+
10+
const sonicConfig: ChainRoutingConfig = [
11+
// WRAPPERS
12+
{
13+
strategy: StrategyRepayWrapper.name(),
14+
match: {
15+
isRepay: true,
16+
swapperModes: [SwapperMode.EXACT_IN],
17+
},
18+
},
19+
{
20+
strategy: StrategyERC4626Wrapper.name(),
21+
match: {
22+
tokensInOrOut: [WSTKSCUSD_SONIC, WSTKSCETH_SONIC],
23+
},
24+
},
25+
// DEFAULTS
26+
{
27+
strategy: StrategyBalmySDK.name(),
28+
config: {
29+
sourcesFilter: {
30+
includeSources: [
31+
"kyberswap",
32+
"paraswap",
33+
"odos",
34+
"1inch",
35+
"li-fi",
36+
"open-ocean",
37+
"uniswap",
38+
"0x",
39+
],
40+
},
41+
},
42+
match: {},
43+
},
44+
]
45+
46+
export default sonicConfig

src/swapService/strategies/strategyERC4626Wrapper.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ const defaultConfig: {
6262
asset: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
6363
assetDustEVault: "0xb3b36220fA7d12f7055dab5c9FD18E860e9a6bF8",
6464
},
65+
{
66+
chainId: 146,
67+
protocol: "wstkscETH",
68+
vault: "0xE8a41c62BB4d5863C6eadC96792cFE90A1f37C47",
69+
asset: "0x455d5f11Fea33A8fa9D3e285930b478B6bF85265",
70+
assetDustEVault: "0x57056B888527A9ca638CA06f2e194eF73a32CAFC",
71+
},
72+
{
73+
chainId: 146,
74+
protocol: "wstkscUSD",
75+
vault: "0x9fb76f7ce5FCeAA2C42887ff441D46095E494206",
76+
asset: "0x4D85bA8c3918359c78Ed09581E5bc7578ba932ba",
77+
assetDustEVault: "0x911Af5Bf5b7dd0F83869Ba857eDfDC3dea8254C2",
78+
},
6579
// {
6680
// chainId: 1,
6781
// protocol: "sUSDS",
@@ -238,6 +252,7 @@ export class StrategyERC4626Wrapper {
238252

239253
const vaultData = this.getSupportedVault(swapParams.tokenIn.addressInfo)
240254
const tokenIn = findToken(swapParams.chainId, vaultData.asset)
255+
console.log("vaultData: ", vaultData)
241256
if (!tokenIn) throw new Error("Inner token not found")
242257
const innerSwapParams = {
243258
...swapParams,

tokenLists/tokenList_146.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,23 @@
133133
"decimals": 18,
134134
"logoURI": "/tokens/146/SolvBTCBBN.webp",
135135
"meta": {}
136+
},
137+
{
138+
"addressInfo": "0x455d5f11Fea33A8fa9D3e285930b478B6bF85265",
139+
"chainId": 146,
140+
"name": "stkscETH",
141+
"symbol": "stkscETH",
142+
"decimals": 18,
143+
"logoURI": "",
144+
"meta": {}
145+
},
146+
{
147+
"addressInfo": "0x4D85bA8c3918359c78Ed09581E5bc7578ba932ba",
148+
"chainId": 146,
149+
"name": "stkscUSD",
150+
"symbol": "stkscUSD",
151+
"decimals": 6,
152+
"logoURI": "",
153+
"meta": {}
136154
}
137155
]

0 commit comments

Comments
 (0)