Skip to content

Commit 7fa1e85

Browse files
committed
use odos enterprice api
1 parent 694e032 commit 7fa1e85

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ OPENOCEAN_API_KEY=""
3131
OKX_API_KEY=""
3232
OKX_PASSPHRASE=""
3333
OKX_SECRET_KEY=""
34+
ODOS_API_KEY=""
3435
ODOS_REFERRAL_CODE=""

src/swapService/config/mainnet.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,6 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
4545
},
4646
match: { isPendlePT: true },
4747
},
48-
49-
// RLP - only include odos for RLP, otherwise rate limits are hit
50-
{
51-
strategy: StrategyBalmySDK.name(),
52-
config: {
53-
sourcesFilter: {
54-
includeSources: [
55-
"kyberswap",
56-
"paraswap",
57-
"odos",
58-
"1inch",
59-
"li-fi",
60-
"open-ocean",
61-
"uniswap",
62-
],
63-
},
64-
},
65-
match: {
66-
tokensInOrOut: [RLP_MAINNET],
67-
},
68-
},
6948
// USD0++ route without open-ocean and combined
7049
{
7150
strategy: StrategyBalmySDK.name(),
@@ -74,7 +53,7 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
7453
includeSources: [
7554
"kyberswap",
7655
"paraswap",
77-
// "odos",
56+
"odos",
7857
"1inch",
7958
"li-fi",
8059
// "open-ocean",
@@ -95,7 +74,7 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
9574
includeSources: [
9675
"kyberswap",
9776
"paraswap",
98-
// "odos",
77+
"odos",
9978
"1inch",
10079
"li-fi",
10180
"open-ocean",
@@ -124,7 +103,7 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
124103
includeSources: [
125104
"kyberswap",
126105
"paraswap",
127-
// "odos",
106+
"odos",
128107
"1inch",
129108
"li-fi",
130109
"open-ocean",

src/swapService/strategies/balmySDK/odosQuoteSource.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ type SourcesConfig =
5151
type OdosSupport = { buyOrders: false; swapAndTransfer: true }
5252
type OdosConfig = {
5353
supportRFQs?: boolean
54-
referralCode?: number
54+
referralCode: number
55+
apiKey: string
5556
} & SourcesConfig
5657
type OdosData = { tx: SourceQuoteTransaction }
5758
export class CustomOdosQuoteSource extends AlwaysValidConfigAndContextSource<
@@ -128,20 +129,28 @@ async function getQuote({
128129
pathViz: false,
129130
disableRFQs: !config?.supportRFQs, // Disable by default
130131
simple,
131-
...(config?.referralCode ? { referralCode: config?.referralCode } : {}),
132+
referralCode: config.referralCode,
133+
}
134+
135+
const headers: HeadersInit = {
136+
"Content-Type": "application/json",
137+
"x-api-key": config.apiKey,
132138
}
133139

134140
const [quoteResponse, routerResponse] = await Promise.all([
135-
fetchService.fetch("https://api.odos.xyz/sor/quote/v2", {
141+
fetchService.fetch("https://enterprise-api.odos.xyz/sor/quote/v2", {
136142
body: JSON.stringify(quoteBody),
137143
method: "POST",
138-
headers: { "Content-Type": "application/json" },
139-
timeout,
140-
}),
141-
fetchService.fetch(`https://api.odos.xyz/info/router/v2/${chainId}`, {
142-
headers: { "Content-Type": "application/json" },
144+
headers,
143145
timeout,
144146
}),
147+
fetchService.fetch(
148+
`https://enterprise-api.odos.xyz/info/router/v2/${chainId}`,
149+
{
150+
headers,
151+
timeout,
152+
},
153+
),
145154
])
146155

147156
if (!quoteResponse.ok) {
@@ -171,11 +180,11 @@ async function getQuote({
171180
const { address } = await routerResponse.json()
172181

173182
const assembleResponse = await fetchService.fetch(
174-
"https://api.odos.xyz/sor/assemble",
183+
"https://enterprise-api.odos.xyz/sor/assemble",
175184
{
176185
body: JSON.stringify({ userAddr, pathId, receiver: recipient }),
177186
method: "POST",
178-
headers: { "Content-Type": "application/json" },
187+
headers,
179188
timeout,
180189
},
181190
)

src/swapService/strategies/strategyBalmySDK.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export class StrategyBalmySDK {
120120
passphrase: String(process.env.OKX_PASSPHRASE),
121121
},
122122
odos: {
123+
apiKey: String(process.env.ODOS_API_KEY),
123124
referralCode: Number(process.env.ODOS_REFERRAL_CODE),
124125
},
125126
},

0 commit comments

Comments
 (0)