@@ -234,12 +234,42 @@ export function getUniV2Adapter({
234234 factory = factory ! . toLowerCase ( ) ;
235235 const cacheKey = `tvl-adapter-cache/cache/uniswap-forks/${ factory } -${ chain } .json` ;
236236
237- let res = await cache . readCache ( cacheKey , { readFromR2Cache : true } ) ;
238- let { pairs, token0s, token1s, symbols } = res ;
239- if ( ! pairs ?. length )
240- throw new Error ( "No pairs found, is there TVL adapter for this already?" ) ;
241- if ( pairs . length > 20 * 1000 )
242- throw new Error ( "Too many pairs found, try using the graph?" ) ;
237+ let pairs : any , symbols : any , token0s : any , token1s : any ;
238+ if ( factory == '0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f' ) {
239+ const pairsLength = await api . call ( {
240+ abi : 'function allPairsLength() view returns (uint256)' ,
241+ target : factory ,
242+ } ) ;
243+ pairs = await api . multiCall ( {
244+ abi : 'function allPairs(uint256) view returns (address)' ,
245+ calls : Array . from ( { length : pairsLength } , ( _ , i ) => ( {
246+ target : factory ,
247+ params : [ i ] ,
248+ } ) ) ,
249+ } ) ;
250+ token0s = await api . multiCall ( {
251+ abi : 'function token0() view returns (address)' ,
252+ calls : pairs . map ( ( i : any ) => ( {
253+ target : i ,
254+ } ) ) ,
255+ } ) ;
256+ token1s = await api . multiCall ( {
257+ abi : 'function token1() view returns (address)' ,
258+ calls : pairs . map ( ( i : any ) => ( {
259+ target : i ,
260+ } ) ) ,
261+ } ) ;
262+ } else {
263+ let res = await cache . readCache ( cacheKey , { readFromR2Cache : true } ) ;
264+ pairs = res . pairs ;
265+ token0s = res . token0s ;
266+ token1s = res . token1s ;
267+ symbols = res . symbols ;
268+ if ( ! pairs ?. length )
269+ throw new Error ( "No pairs found, is there TVL adapter for this already?" ) ;
270+ if ( pairs . length > 20 * 1000 )
271+ throw new Error ( "Too many pairs found, try using the graph?" ) ;
272+ }
243273
244274 pairs = pairs . map ( ( i : any ) => i . toLowerCase ( ) ) ;
245275 token0s = token0s . map ( ( i : any ) => i . toLowerCase ( ) ) ;
0 commit comments