Skip to content

Commit ef78746

Browse files
committed
fix: balmy sdk config
1 parent 716b7e6 commit ef78746

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/swapService/strategies/strategyBalmySDK.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import { CustomSourceList } from "./balmySDK/customSourceList"
3535

3636
const DAO_MULTISIG = "0xcAD001c30E96765aC90307669d578219D4fb1DCe"
37+
const DEFAULT_TIMEOUT = "30000"
3738
// TODO config
3839
const BINARY_SEARCH_EXCLUDE_SOURCES = ["paraswap"] // paraswap is rate limited and fails if selected as best source for binary search
3940

@@ -48,24 +49,29 @@ type SourcesFilter =
4849
>
4950
| undefined
5051

51-
export const defaultConfig: {
52+
export type BalmyStrategyConfig = {
5253
referrer: {
5354
address: Address
5455
name: string
5556
}
57+
timeout: string
5658
sourcesFilter: SourcesFilter
5759
tryExactOut?: boolean
5860
onlyExactOut?: boolean
59-
} = {
61+
}
62+
63+
export const defaultConfig: BalmyStrategyConfig = {
6064
referrer: {
6165
address: DAO_MULTISIG,
6266
name: "euler",
6367
},
68+
timeout: DEFAULT_TIMEOUT,
6469
sourcesFilter: undefined,
6570
tryExactOut: false, // tries buy order search through balmy before falling back to binary search.
6671
// Use only if exact out behavior is known for source
6772
onlyExactOut: false, // don't try overswapping when exact out not available
6873
}
74+
6975
export class StrategyBalmySDK {
7076
static name() {
7177
return "balmy_sdk"
@@ -75,7 +81,8 @@ export class StrategyBalmySDK {
7581

7682
private readonly sdk
7783

78-
constructor(match = {}, config = defaultConfig) {
84+
constructor(match = {}, config?: BalmyStrategyConfig) {
85+
this.config = { ...defaultConfig, ...(config || {}) }
7986
const fetchService = buildFetchService()
8087
const providerService = buildProviderService()
8188

@@ -88,7 +95,7 @@ export class StrategyBalmySDK {
8895
defaultConfig: {
8996
global: {
9097
disableValidation: true,
91-
referrer: config.referrer,
98+
referrer: this.config.referrer,
9299
},
93100
custom: {
94101
"1inch": {
@@ -109,7 +116,6 @@ export class StrategyBalmySDK {
109116
} as BuildParams
110117
this.sdk = buildSDK(buildParams)
111118
this.match = match
112-
this.config = config
113119
}
114120

115121
async supports(swapParams: SwapParams) {
@@ -245,7 +251,7 @@ export class StrategyBalmySDK {
245251
if (this.config.sourcesFilter?.includeSources) {
246252
sourcesFilter = {
247253
includeSources: this.config.sourcesFilter.includeSources.filter(
248-
(s) => !BINARY_SEARCH_EXCLUDE_SOURCES.includes(s),
254+
(s: string) => !BINARY_SEARCH_EXCLUDE_SOURCES.includes(s),
249255
),
250256
}
251257
} else if (this.config.sourcesFilter?.excludeSources) {
@@ -391,7 +397,7 @@ export class StrategyBalmySDK {
391397
choose: {
392398
by: "most-swapped-accounting-for-gas",
393399
},
394-
timeout: "30000", // TODO config
400+
timeout: this.config.timeout || DEFAULT_TIMEOUT,
395401
},
396402
})
397403

0 commit comments

Comments
 (0)