@@ -116,7 +116,7 @@ export async function fetchVault(
116116 supplyQueueSize ,
117117 withdrawQueueSize ,
118118 hasPublicAllocator ,
119- isMetaMorpho ,
119+ isMetaMorphoV1_1 ,
120120 ] = await Promise . all ( [
121121 fetchVaultConfig ( address , client , parameters ) ,
122122 readContract ( client , {
@@ -223,35 +223,27 @@ export async function fetchVault(
223223 functionName : "isAllocator" ,
224224 args : [ publicAllocator ] ,
225225 } ) ,
226- ( async ( ) => {
227- try {
228- const isMetaMorphoV1_1 = await readContract ( client , {
229- ... parameters ,
230- address : metaMorphoFactory ,
231- abi : metaMorphoFactoryAbi ,
232- functionName : "isMetaMorpho" ,
233- args : [ address ] ,
234- } ) ;
235- if ( isMetaMorphoV1_1 ) return true ;
236- } catch { }
237- // Fallback to the MetaMorphoV1.0 factory on Ethereum (1) and Base (8453)
238- if ( parameters . chainId === 1 || parameters . chainId === 8453 ) {
239- const isMetaMorphoV1_0 = await readContract ( client , {
226+ readContract ( client , {
227+ ... parameters ,
228+ address : metaMorphoFactory ,
229+ abi : metaMorphoFactoryAbi ,
230+ functionName : "isMetaMorpho" ,
231+ args : [ address ] ,
232+ } ) . catch ( ( ) => false ) ,
233+ ] ) ;
234+
235+ // Fallback to the MetaMorphoV1.0 factory on Ethereum (1) and Base (8453)
236+ const isMetaMorphoV1_0Promise =
237+ ! isMetaMorphoV1_1 &&
238+ ( parameters . chainId === 1 || parameters . chainId === 8453 )
239+ ? readContract ( client , {
240240 ...parameters ,
241241 address : "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101" ,
242242 abi : metaMorphoFactoryAbi ,
243243 functionName : "isMetaMorpho" ,
244244 args : [ address ] ,
245- } ) ;
246- if ( isMetaMorphoV1_0 ) return true ;
247- }
248- return false ;
249- } ) ( ) ,
250- ] ) ;
251-
252- if ( ! isMetaMorpho ) {
253- throw new UnknownOfFactory ( metaMorphoFactory , address ) ;
254- }
245+ } )
246+ : Promise . resolve ( false ) ;
255247
256248 let publicAllocatorConfigPromise :
257249 | Promise < VaultPublicAllocatorConfig >
@@ -281,8 +273,8 @@ export async function fetchVault(
281273 } ) ,
282274 ] ) . then ( ( [ admin , fee , accruedFee ] ) => ( { admin, fee, accruedFee } ) ) ;
283275
284- const [ supplyQueue , withdrawQueue , publicAllocatorConfig ] = await Promise . all (
285- [
276+ const [ supplyQueue , withdrawQueue , publicAllocatorConfig , isMetaMorphoV1_0 ] =
277+ await Promise . all ( [
286278 Promise . all (
287279 Array . from (
288280 { length : Number ( supplyQueueSize ) } ,
@@ -310,8 +302,13 @@ export async function fetchVault(
310302 ) ,
311303 ) ,
312304 publicAllocatorConfigPromise ,
313- ] ,
314- ) ;
305+ isMetaMorphoV1_0Promise ,
306+ ] ) ;
307+
308+ const isMetaMorpho = isMetaMorphoV1_1 || isMetaMorphoV1_0 ;
309+ if ( ! isMetaMorpho ) {
310+ throw new UnknownOfFactory ( metaMorphoFactory , address ) ;
311+ }
315312
316313 return new Vault ( {
317314 ...config ,
0 commit comments