@@ -34,6 +34,7 @@ import {
34
34
import { CustomSourceList } from "./balmySDK/customSourceList"
35
35
36
36
const DAO_MULTISIG = "0xcAD001c30E96765aC90307669d578219D4fb1DCe"
37
+ const DEFAULT_TIMEOUT = "30000"
37
38
// TODO config
38
39
const BINARY_SEARCH_EXCLUDE_SOURCES = [ "paraswap" ] // paraswap is rate limited and fails if selected as best source for binary search
39
40
@@ -48,24 +49,29 @@ type SourcesFilter =
48
49
>
49
50
| undefined
50
51
51
- export const defaultConfig : {
52
+ export type BalmyStrategyConfig = {
52
53
referrer : {
53
54
address : Address
54
55
name : string
55
56
}
57
+ timeout : string
56
58
sourcesFilter : SourcesFilter
57
59
tryExactOut ?: boolean
58
60
onlyExactOut ?: boolean
59
- } = {
61
+ }
62
+
63
+ export const defaultConfig : BalmyStrategyConfig = {
60
64
referrer : {
61
65
address : DAO_MULTISIG ,
62
66
name : "euler" ,
63
67
} ,
68
+ timeout : DEFAULT_TIMEOUT ,
64
69
sourcesFilter : undefined ,
65
70
tryExactOut : false , // tries buy order search through balmy before falling back to binary search.
66
71
// Use only if exact out behavior is known for source
67
72
onlyExactOut : false , // don't try overswapping when exact out not available
68
73
}
74
+
69
75
export class StrategyBalmySDK {
70
76
static name ( ) {
71
77
return "balmy_sdk"
@@ -75,7 +81,8 @@ export class StrategyBalmySDK {
75
81
76
82
private readonly sdk
77
83
78
- constructor ( match = { } , config = defaultConfig ) {
84
+ constructor ( match = { } , config ?: BalmyStrategyConfig ) {
85
+ this . config = { ...defaultConfig , ...( config || { } ) }
79
86
const fetchService = buildFetchService ( )
80
87
const providerService = buildProviderService ( )
81
88
@@ -88,7 +95,7 @@ export class StrategyBalmySDK {
88
95
defaultConfig : {
89
96
global : {
90
97
disableValidation : true ,
91
- referrer : config . referrer ,
98
+ referrer : this . config . referrer ,
92
99
} ,
93
100
custom : {
94
101
"1inch" : {
@@ -109,7 +116,6 @@ export class StrategyBalmySDK {
109
116
} as BuildParams
110
117
this . sdk = buildSDK ( buildParams )
111
118
this . match = match
112
- this . config = config
113
119
}
114
120
115
121
async supports ( swapParams : SwapParams ) {
@@ -245,7 +251,7 @@ export class StrategyBalmySDK {
245
251
if ( this . config . sourcesFilter ?. includeSources ) {
246
252
sourcesFilter = {
247
253
includeSources : this . config . sourcesFilter . includeSources . filter (
248
- ( s ) => ! BINARY_SEARCH_EXCLUDE_SOURCES . includes ( s ) ,
254
+ ( s : string ) => ! BINARY_SEARCH_EXCLUDE_SOURCES . includes ( s ) ,
249
255
) ,
250
256
}
251
257
} else if ( this . config . sourcesFilter ?. excludeSources ) {
@@ -391,7 +397,7 @@ export class StrategyBalmySDK {
391
397
choose : {
392
398
by : "most-swapped-accounting-for-gas" ,
393
399
} ,
394
- timeout : "30000" , // TODO config
400
+ timeout : this . config . timeout || DEFAULT_TIMEOUT ,
395
401
} ,
396
402
} )
397
403
0 commit comments