@@ -86,20 +86,37 @@ export class StrategyBalmySDK {
8686
8787 private readonly sdk
8888
89- constructor ( match = { } , config ?: BalmyStrategyConfig ) {
89+ constructor ( match = { } , config ?: BalmyStrategyConfig , provider ?: string ) {
9090 const allPendleAggregators = [
9191 ...new Set ( Object . values ( pendleAggregators ) . flat ( ) ) ,
9292 ]
9393
94- if ( config ?. sourcesFilter ?. includeSources ?. includes ( "pendle" ) ) {
95- config . sourcesFilter . includeSources . push (
94+ let configClone = structuredClone ( config )
95+
96+ if ( configClone ?. sourcesFilter ?. includeSources ?. includes ( "pendle" ) ) {
97+ configClone . sourcesFilter . includeSources . push (
9698 ...allPendleAggregators . map ( ( aggregator ) => `pendle-${ aggregator } ` ) ,
9799 )
98- config . sourcesFilter . includeSources =
99- config . sourcesFilter . includeSources . filter ( ( s ) => s !== "pendle" )
100+ configClone . sourcesFilter . includeSources =
101+ configClone . sourcesFilter . includeSources . filter ( ( s ) => s !== "pendle" )
102+ }
103+
104+ if ( provider ) {
105+ if ( ! configClone ) configClone = { } as BalmyStrategyConfig
106+ if ( configClone . sourcesFilter ?. excludeSources ?. includes ( provider ) ) {
107+ configClone . sourcesFilter = { includeSources : [ ] }
108+ } else {
109+ configClone . sourcesFilter = {
110+ includeSources : configClone . sourcesFilter ?. includeSources
111+ ? configClone . sourcesFilter . includeSources . filter (
112+ ( s ) => s === provider ,
113+ )
114+ : [ provider ] ,
115+ }
116+ }
100117 }
101118
102- this . config = { ...defaultConfig , ...( config || { } ) }
119+ this . config = { ...defaultConfig , ...( configClone || { } ) }
103120 const fetchService = buildFetchService ( )
104121 const providerService = buildProviderService ( {
105122 source : {
@@ -129,9 +146,6 @@ export class StrategyBalmySDK {
129146 "li-fi" : {
130147 apiKey : String ( process . env . LIFI_API_KEY ) ,
131148 } ,
132- // pendle: {
133- // apiKey: String(process.env.PENDLE_API_KEY),
134- // },
135149 "open-ocean" : {
136150 apiKey : String ( process . env . OPENOCEAN_API_KEY ) ,
137151 } ,
@@ -195,7 +209,9 @@ export class StrategyBalmySDK {
195209 return (
196210 ! isExactInRepay ( swapParams ) &&
197211 ( this . sdk . quoteService . supportedChains ( ) . includes ( swapParams . chainId ) ||
198- swapParams . chainId === 1923 ) // TODO fix!
212+ swapParams . chainId === 1923 ) && // TODO fix!
213+ ( ! this . config . sourcesFilter ?. includeSources ||
214+ this . config . sourcesFilter . includeSources . length > 0 )
199215 )
200216 }
201217
0 commit comments