@@ -107,7 +107,7 @@ export const TWO_HOP_SOURCE_FILTERS = SourceFilters.all().exclude([
107
107
export const BATCH_SOURCE_FILTERS = SourceFilters . all ( ) . exclude ( [ ERC20BridgeSource . MultiHop , ERC20BridgeSource . Native ] ) ;
108
108
109
109
export type PoolsCacheMap = { [ key in Exclude < SourcesWithPoolsCache , ERC20BridgeSource . BalancerV2 > ] : PoolsCache } & {
110
- [ ERC20BridgeSource . BalancerV2 ] : BalancerV2SwapInfoCache ;
110
+ [ ERC20BridgeSource . BalancerV2 ] : BalancerV2SwapInfoCache | undefined ;
111
111
} ;
112
112
113
113
// tslint:disable:no-inferred-empty-object-type no-unbound-method
@@ -151,7 +151,10 @@ export class SamplerOperations {
151
151
) ,
152
152
[ ERC20BridgeSource . Balancer ] : new BalancerPoolsCache ( ) ,
153
153
[ ERC20BridgeSource . Cream ] : new CreamPoolsCache ( ) ,
154
- [ ERC20BridgeSource . BalancerV2 ] : new BalancerV2SwapInfoCache ( chainId ) ,
154
+ [ ERC20BridgeSource . BalancerV2 ] :
155
+ BALANCER_V2_VAULT_ADDRESS_BY_CHAIN [ chainId ] === NULL_ADDRESS
156
+ ? undefined
157
+ : new BalancerV2SwapInfoCache ( chainId ) ,
155
158
} ;
156
159
157
160
const aaveSubgraphUrl = AAVE_V2_SUBGRAPH_URL_BY_CHAIN_ID [ chainId ] ;
@@ -571,7 +574,7 @@ export class SamplerOperations {
571
574
} ) ;
572
575
}
573
576
574
- public getBalancerV2MulthopSellQuotes (
577
+ public getBalancerV2MultihopSellQuotes (
575
578
vault : string ,
576
579
quoteSwaps : BalancerSwapInfo , // Should always be sell swap steps.
577
580
fillSwaps : BalancerSwapInfo , // Should always be sell swap steps.
@@ -592,7 +595,7 @@ export class SamplerOperations {
592
595
} ) ;
593
596
}
594
597
595
- public getBalancerV2MulthopBuyQuotes (
598
+ public getBalancerV2MultihopBuyQuotes (
596
599
vault : string ,
597
600
quoteSwaps : BalancerSwapInfo , // Should always be buy swap steps.
598
601
fillSwaps : BalancerSwapInfo , // Should always be a sell quote.
@@ -1499,15 +1502,19 @@ export class SamplerOperations {
1499
1502
) ,
1500
1503
) ;
1501
1504
case ERC20BridgeSource . BalancerV2 : {
1502
- const swaps = this . poolsCaches [ source ] . getCachedSwapInfoForPair ( takerToken , makerToken ) ;
1505
+ const cache = this . poolsCaches [ source ] ;
1506
+ if ( ! cache ) {
1507
+ return [ ] ;
1508
+ }
1503
1509
1510
+ const swaps = cache . getCachedSwapInfoForPair ( takerToken , makerToken ) ;
1504
1511
const vault = BALANCER_V2_VAULT_ADDRESS_BY_CHAIN [ this . chainId ] ;
1505
1512
if ( ! swaps || vault === NULL_ADDRESS ) {
1506
1513
return [ ] ;
1507
1514
}
1508
1515
// Changed to retrieve queryBatchSwap for swap steps > 1 of length
1509
1516
return swaps . swapInfoExactIn . map ( swapInfo =>
1510
- this . getBalancerV2MulthopSellQuotes ( vault , swapInfo , swapInfo , takerFillAmounts , source ) ,
1517
+ this . getBalancerV2MultihopSellQuotes ( vault , swapInfo , swapInfo , takerFillAmounts , source ) ,
1511
1518
) ;
1512
1519
}
1513
1520
case ERC20BridgeSource . Beethovenx : {
@@ -1822,15 +1829,19 @@ export class SamplerOperations {
1822
1829
) ,
1823
1830
) ;
1824
1831
case ERC20BridgeSource . BalancerV2 : {
1825
- const swaps = this . poolsCaches [ source ] . getCachedSwapInfoForPair ( takerToken , makerToken ) ;
1832
+ const cache = this . poolsCaches [ source ] ;
1833
+ if ( ! cache ) {
1834
+ return [ ] ;
1835
+ }
1826
1836
1837
+ const swaps = cache . getCachedSwapInfoForPair ( takerToken , makerToken ) ;
1827
1838
const vault = BALANCER_V2_VAULT_ADDRESS_BY_CHAIN [ this . chainId ] ;
1828
1839
if ( ! swaps || vault === NULL_ADDRESS ) {
1829
1840
return [ ] ;
1830
1841
}
1831
1842
// Changed to retrieve queryBatchSwap for swap steps > 1 of length
1832
1843
return swaps . swapInfoExactOut . map ( ( quoteSwapInfo , i ) =>
1833
- this . getBalancerV2MulthopBuyQuotes (
1844
+ this . getBalancerV2MultihopBuyQuotes (
1834
1845
vault ,
1835
1846
quoteSwapInfo ,
1836
1847
swaps . swapInfoExactIn [ i ] ,
0 commit comments