Skip to content

Commit 2890af7

Browse files
committed
feat: add base config
1 parent 24750a9 commit 2890af7

File tree

7 files changed

+188
-7
lines changed

7 files changed

+188
-7
lines changed

src/common/utils/tokenList.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Address } from "viem"
22
import tokenList1 from "../../tokenLists/tokenList_1"
3+
import tokenList8453 from "../../tokenLists/tokenList_8543"
34

45
export type TokenListItem = {
56
addressInfo: Address
@@ -17,6 +18,7 @@ export type TokenListItem = {
1718

1819
const cache: Record<number, TokenListItem[]> = {
1920
1: tokenList1 as TokenListItem[],
21+
8453: tokenList8453 as TokenListItem[],
2022
}
2123

2224
export default function getTokenList(chainId: number): TokenListItem[] {

src/swapService/config/base.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { type ChainRoutingConfig, SwapperMode } from "../interface"
2+
import { StrategyBalmySDK, StrategyRepayWrapper } from "../strategies"
3+
4+
const LBTC_BASE = "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
5+
6+
const baseRoutingConfig: ChainRoutingConfig = [
7+
// WRAPPERS
8+
{
9+
strategy: StrategyRepayWrapper.name(),
10+
match: {
11+
isRepay: true,
12+
swapperModes: [SwapperMode.EXACT_IN],
13+
},
14+
},
15+
// SPECIAL CASE TOKENS
16+
{
17+
strategy: StrategyBalmySDK.name(),
18+
config: {
19+
sourcesFilter: {
20+
includeSources: [
21+
"kyberswap",
22+
"paraswap",
23+
"odos",
24+
"1inch",
25+
"li-fi",
26+
"open-ocean",
27+
],
28+
},
29+
},
30+
match: {
31+
tokensInOrOut: [LBTC_BASE],
32+
},
33+
},
34+
// DEFAULTS
35+
{
36+
strategy: StrategyBalmySDK.name(),
37+
config: {
38+
sourcesFilter: {
39+
includeSources: ["1inch"],
40+
},
41+
},
42+
match: {},
43+
},
44+
// FALLBACKS
45+
{
46+
strategy: StrategyBalmySDK.name(),
47+
config: {
48+
sourcesFilter: {
49+
includeSources: [
50+
"kyberswap",
51+
"paraswap",
52+
"odos",
53+
"1inch",
54+
"li-fi",
55+
"open-ocean",
56+
"conveyor",
57+
"uniswap",
58+
],
59+
},
60+
},
61+
match: {},
62+
},
63+
]
64+
65+
export default baseRoutingConfig

src/swapService/config/default.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { type ChainRoutingConfig, SwapperMode } from "../interface"
2+
import { StrategyBalmySDK, StrategyRepayWrapper } from "../strategies"
3+
4+
const defaultRoutingConfig: 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: [
19+
"kyberswap",
20+
"paraswap",
21+
"odos",
22+
"1inch",
23+
"li-fi",
24+
"open-ocean",
25+
"conveyor",
26+
"uniswap",
27+
],
28+
},
29+
},
30+
match: {},
31+
},
32+
]
33+
34+
export default defaultRoutingConfig

src/swapService/config/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import { base, mainnet } from "viem/chains"
12
import type { RoutingConfig } from "../interface"
3+
import baseRoutingConfig from "./base"
4+
import defaultRoutingConfig from "./default"
25
import mainnetRoutingConfig from "./mainnet"
36

47
const routingConfig: RoutingConfig = {
5-
"1": mainnetRoutingConfig,
8+
[mainnet.id]: mainnetRoutingConfig,
9+
[base.id]: baseRoutingConfig,
610
}
711

8-
export default routingConfig
12+
export const getRoutingConfig = (chainId: number) => {
13+
return routingConfig[chainId] || defaultRoutingConfig
14+
}

src/swapService/config/mainnet.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { type ChainRoutingConfig, SwapperMode } from "../interface"
22
import {
3-
Strategy1Inch,
43
StrategyBalmySDK,
54
StrategyCombinedUniswap,
65
StrategyERC4626Wrapper,
7-
StrategyLifi,
86
StrategyMTBILL,
9-
StrategyPendle,
107
StrategyRepayWrapper,
118
} from "../strategies"
129
import { MTBILL_MAINNET } from "../strategies/strategyMTBILL"

src/swapService/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StatusCodes } from "http-status-codes"
2-
import routingConfig from "./config"
2+
import { getRoutingConfig } from "./config"
33
import type {
44
ChainRoutingConfig,
55
RoutingItem,
@@ -14,7 +14,7 @@ function loadPipeline(swapParams: SwapParams) {
1414
if (swapParams.routingOverride) {
1515
routing = swapParams.routingOverride
1616
} else {
17-
routing = routingConfig[String(swapParams.chainId)]
17+
routing = getRoutingConfig(swapParams.chainId)
1818
if (!routing)
1919
throw new ApiError(
2020
StatusCodes.NOT_FOUND,

src/tokenLists/tokenList_8543.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
export default [
2+
{
3+
addressInfo: "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
4+
chainId: 1,
5+
name: "Coinbase Wrapped BTC",
6+
symbol: "CBBTC",
7+
decimals: 8,
8+
logoURI:
9+
"https://coin-images.coingecko.com/coins/images/40143/large/cbbtc.webp?1726136727",
10+
meta: {},
11+
},
12+
{
13+
addressInfo: "0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22",
14+
chainId: 8453,
15+
name: "Coinbase Wrapped Staked ETH",
16+
symbol: "cbETH",
17+
decimals: 18,
18+
logoURI: "/tokens/8453/cbeth.png",
19+
meta: {},
20+
},
21+
{
22+
addressInfo: "0x4200000000000000000000000000000000000006",
23+
chainId: 8453,
24+
name: "Wrapped Ether",
25+
symbol: "WETH",
26+
decimals: 18,
27+
logoURI:
28+
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
29+
meta: {},
30+
},
31+
{
32+
addressInfo: "0x60a3e35cc302bfa44cb288bc5a4f316fdb1adb42",
33+
chainId: 8453,
34+
name: "EURC",
35+
symbol: "EURC",
36+
decimals: 6,
37+
logoURI: "/tokens/8453/eurc.png",
38+
meta: {},
39+
},
40+
{
41+
addressInfo: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
42+
chainId: 8453,
43+
name: "USDC",
44+
symbol: "USDC",
45+
decimals: 6,
46+
logoURI: "/tokens/8453/usdc.png",
47+
meta: {},
48+
},
49+
{
50+
addressInfo: "0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452",
51+
chainId: 8453,
52+
name: "Wrapped liquid staked Ether 2.0",
53+
symbol: "wstETH",
54+
decimals: 18,
55+
logoURI: "/tokens/8453/wsteth.png",
56+
meta: {},
57+
},
58+
{
59+
addressInfo: "0x04c0599ae5a44757c0af6f9ec3b93da8976c150a",
60+
chainId: 8453,
61+
name: "Wrapped eETH",
62+
symbol: "weETH",
63+
decimals: 18,
64+
logoURI: "/tokens/8453/weeth.svg",
65+
meta: {},
66+
},
67+
{
68+
addressInfo: "0xecac9c5f704e954931349da37f60e39f515c11c1",
69+
chainId: 8453,
70+
name: "Lombard Staked Bitcoin",
71+
symbol: "LBTC",
72+
decimals: 8,
73+
logoURI:
74+
"https://coin-images.coingecko.com/coins/images/39969/large/LBTC_Logo.png?1724959872",
75+
meta: {},
76+
},
77+
]

0 commit comments

Comments
 (0)