Skip to content

Commit e6de071

Browse files
committed
Merge branch 'master' into multiple-quotes
2 parents af1b7e1 + 325c10f commit e6de071

31 files changed

+1107
-42
lines changed

.env.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ RPC_URL_31337=""
2626
RPC_URL_146=""
2727
# bera
2828
RPC_URL_80094=""
29+
# unichain
30+
RPC_URL_130=""
31+
# bob
32+
RPC_URL_60808=""
2933

3034
# Provider API keys
3135
LIFI_API_KEY=""
@@ -37,4 +41,5 @@ OKX_PASSPHRASE=""
3741
OKX_SECRET_KEY=""
3842
ODOS_API_KEY=""
3943
ODOS_REFERRAL_CODE=""
40-
OOGABOOGA_API_KEY=""
44+
OOGABOOGA_API_KEY=""
45+
OX_API_KEY=""

src/api/routes/swap/swapRouter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function parseRequest(request: Request): SwapParams {
101101
// TODO
102102
// if (!isSupportedChainId(validatedParams.chainId)) {
103103
// throw new Error("Unsupported chainId")
104-
// }
104+
// }
105105

106106
const chainId = validatedParams.chainId
107107
const tokenIn = findToken(chainId, validatedParams.tokenIn)

src/common/utils/contractBook.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const contractBook: any = {
1010
[1923]: "0x05Eb1A647265D974a1B0A57206048312604Ac6C3",
1111
[146]: "0xbAf5B12c92711a3657DD4adA6b3C7801e83Bb56a",
1212
[80094]: "0x4A35e6A872cf35623cd3fD07ebECEDFc0170D705",
13+
[130]: "0x319E8ecd3BaB57fE684ca1aCfaB60c5603087B3A",
14+
[60808]: "0x697Ca30D765c1603890D88AAffBa3BeCCe72059d",
1315
},
1416
},
1517
swapVerifier: {
@@ -21,6 +23,8 @@ const contractBook: any = {
2123
[1923]: "0x392C1570b3Bf29B113944b759cAa9a9282DA12Fe",
2224
[146]: "0x003ef4048b45a5A79D4499aaBd52108B3Bc9209f",
2325
[80094]: "0x6fFf8Ac4AB123B62FF5e92aBb9fF702DCBD6C939",
26+
[130]: "0x7eaf8C22480129E5D7426e3A33880D7bE19B50a7",
27+
[60808]: "0x296041DbdBC92171293F23c0a31e1574b791060d",
2428
},
2529
},
2630
}

src/common/utils/tokenList.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ export type TokenListItem = {
1717

1818
const cache: Record<number, TokenListItem[]> = {}
1919
;(function buildCache() {
20-
const dir = `${__dirname}/../../tokenLists`
21-
const files = fs.readdirSync(dir)
20+
let dir = `${__dirname}/../tokenLists`
21+
let files
22+
try {
23+
files = fs.readdirSync(dir)
24+
} catch {
25+
dir = `${__dirname}/../../../tokenLists`
26+
files = fs.readdirSync(dir)
27+
}
2228
for (const file of files) {
2329
const match = file.match(/(\d+)/g)
2430
if (!match) throw new Error("Invalid tokenlist file")

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/base.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const baseRoutingConfig: ChainRoutingConfig = [
3535
strategy: StrategyBalmySDK.name(),
3636
config: {
3737
sourcesFilter: {
38-
includeSources: ["odos", "open-ocean", "uniswap"],
38+
includeSources: ["odos", "uniswap", "open-ocean"],
3939
},
4040
},
4141
match: {
@@ -56,6 +56,7 @@ const baseRoutingConfig: ChainRoutingConfig = [
5656
"open-ocean",
5757
// "conveyor",
5858
"uniswap",
59+
"magpie",
5960
],
6061
},
6162
},

src/swapService/config/bob.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { type ChainRoutingConfig, SwapperMode } from "../interface"
2+
import { StrategyBalmySDK, StrategyRepayWrapper } from "../strategies"
3+
4+
const bobRoutingConfig: ChainRoutingConfig = [
5+
// WRAPPERS
6+
{
7+
strategy: StrategyRepayWrapper.name(),
8+
match: {
9+
isRepay: true,
10+
swapperModes: [SwapperMode.EXACT_IN],
11+
},
12+
},
13+
// DEFAULTS
14+
{
15+
strategy: StrategyBalmySDK.name(),
16+
config: {
17+
sourcesFilter: {
18+
includeSources: ["oku_bob_icecreamswap", "oku_bob_uniswap"],
19+
},
20+
},
21+
match: {},
22+
},
23+
]
24+
25+
export default bobRoutingConfig

src/swapService/config/default.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const defaultRoutingConfig: ChainRoutingConfig = [
2323
"li-fi",
2424
"open-ocean",
2525
"uniswap",
26+
"0x",
27+
"oku",
2628
],
2729
},
2830
},

src/swapService/config/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ import { base, mainnet } from "viem/chains"
22
import type { RoutingConfig } from "../interface"
33
import baseRoutingConfig from "./base"
44
import beraRoutingConfig from "./bera"
5+
import bobRoutingConfig from "./bob"
56
import defaultRoutingConfig from "./default"
67
import mainnetRoutingConfig from "./mainnet"
8+
import sonicRoutingConfig from "./sonic"
79
import swellRoutingConfig from "./swell"
810

911
const routingConfig: RoutingConfig = {
1012
[mainnet.id]: mainnetRoutingConfig,
1113
[base.id]: baseRoutingConfig,
1214
[1923]: swellRoutingConfig,
1315
[80094]: beraRoutingConfig,
16+
[60808]: bobRoutingConfig,
17+
[146]: sonicRoutingConfig,
1418
}
1519

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

src/swapService/config/mainnet.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
StrategyERC4626Wrapper,
77
StrategyIdleCDOTranche,
88
StrategyMidas,
9+
StrategyRedirectDepositWrapper,
910
StrategyRepayWrapper,
1011
} from "../strategies"
1112

@@ -16,11 +17,14 @@ const WUSDL_MAINNET = "0x7751E2F4b8ae93EF6B79d86419d42FE3295A4559"
1617
const PT_WSTUSR1740182579 = "0xd0097149aa4cc0d0e1fc99b8bd73fc17dc32c1e9"
1718
const PT_WSTUSR_27MAR2025_MAINNET = "0xA8c8861b5ccF8CCe0ade6811CD2A7A7d3222B0B8"
1819
const USD0PLUSPLUS_MAINNET = "0x35d8949372d46b7a3d5a56006ae77b215fc69bc0"
20+
const YNETH_MAINNET = "0x09db87A538BD693E9d08544577d5cCfAA6373A48"
1921
const YNETHX_MAINNET = "0x657d9aba1dbb59e53f9f3ecaa878447dcfc96dcb"
2022
const IDLEAATRANCHEFASANARA_MAINNET =
2123
"0x45054c6753b4Bce40C5d54418DabC20b070F85bE"
2224
const CUSDOUSDC_CURVELP_MAINNET = "0x90455bd11Ce8a67C57d467e634Dc142b8e4105Aa"
2325

26+
const USUAL_USD0_VAULT_MAINNET = "0xd001f0a15D272542687b2677BA627f48A4333b5d"
27+
2428
const mainnetRoutingConfig: ChainRoutingConfig = [
2529
// WRAPPERS
2630
{
@@ -46,7 +50,12 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
4650
{
4751
strategy: StrategyERC4626Wrapper.name(),
4852
match: {
49-
tokensInOrOut: [WSTUSR_MAINNET, PT_WSTUSR1740182579, YNETHX_MAINNET],
53+
tokensInOrOut: [
54+
WSTUSR_MAINNET,
55+
PT_WSTUSR1740182579,
56+
YNETH_MAINNET,
57+
YNETHX_MAINNET,
58+
],
5059
excludeTokensInOrOut: [PT_WSTUSR_27MAR2025_MAINNET],
5160
},
5261
},
@@ -59,44 +68,37 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
5968
},
6069
match: { isPendlePT: true },
6170
},
62-
// USD0++ route without open-ocean and combined
71+
// WUSDL with paraswap
6372
{
6473
strategy: StrategyBalmySDK.name(),
6574
config: {
6675
sourcesFilter: {
6776
includeSources: [
6877
"kyberswap",
69-
// "paraswap",
78+
"paraswap",
7079
"odos",
7180
"1inch",
7281
"li-fi",
73-
// "open-ocean",
82+
"open-ocean",
7483
"uniswap",
84+
"magpie",
7585
],
7686
},
7787
},
7888
match: {
79-
tokensInOrOut: [USD0PLUSPLUS_MAINNET],
89+
tokensInOrOut: [WUSDL_MAINNET],
8090
},
8191
},
82-
// WUSDL with paraswap
8392
{
8493
strategy: StrategyBalmySDK.name(),
8594
config: {
8695
sourcesFilter: {
87-
includeSources: [
88-
"kyberswap",
89-
"paraswap",
90-
"odos",
91-
"1inch",
92-
"li-fi",
93-
// "open-ocean",
94-
"uniswap",
95-
],
96+
includeSources: ["1inch"],
9697
},
9798
},
9899
match: {
99-
tokensInOrOut: [WUSDL_MAINNET],
100+
swapperModes: [SwapperMode.EXACT_IN],
101+
tokensInOrOut: [USD0PLUSPLUS_MAINNET],
100102
},
101103
},
102104
// DEFAULTS
@@ -112,6 +114,7 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
112114
"li-fi",
113115
"open-ocean",
114116
"uniswap",
117+
"magpie",
115118
],
116119
},
117120
},
@@ -123,17 +126,18 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
123126
strategy: StrategyCombinedUniswap.name(),
124127
match: {
125128
swapperModes: [SwapperMode.TARGET_DEBT],
126-
excludeTokensInOrOut: [
127-
RLP_MAINNET,
128-
SUSDS_MAINNET,
129-
USD0PLUSPLUS_MAINNET,
130-
WUSDL_MAINNET,
131-
],
129+
excludeTokensInOrOut: [RLP_MAINNET, SUSDS_MAINNET, WUSDL_MAINNET],
132130
},
133131
},
134132
// FALLBACKS
135-
136-
// Binary search overswap for target debt
133+
// If exact out for Usual's USD0 repay doesn't work, over swap with deposit to escrow
134+
{
135+
strategy: StrategyRedirectDepositWrapper.name(),
136+
match: {
137+
repayVaults: [USUAL_USD0_VAULT_MAINNET],
138+
},
139+
},
140+
// Binary search overswap for target debt
137141
{
138142
strategy: StrategyBalmySDK.name(),
139143
config: {
@@ -146,6 +150,7 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
146150
"li-fi",
147151
"open-ocean",
148152
"uniswap",
153+
"magpie",
149154
],
150155
},
151156
},

0 commit comments

Comments
 (0)