@@ -181,13 +181,19 @@ export async function fetchVaultMarketsViem(
181181 const perMarketResults = await client . multicall ( { contracts : perMarketCalls , allowFailure : false } )
182182
183183 // Parse per-market results (4 calls per market)
184+ // viem returns multi-output functions as arrays, so destructure by position.
184185 const parsed = allIds . map ( ( _ , i ) => {
185186 const base = i * 4
186- const state = perMarketResults [ base ] as unknown as { totalSupplyAssets : bigint ; totalSupplyShares : bigint ; totalBorrowAssets : bigint ; fee : bigint }
187- const pos = perMarketResults [ base + 1 ] as unknown as { supplyShares : bigint }
188- const params = perMarketResults [ base + 2 ] as unknown as { loanToken : `0x${string } `; irm : `0x${string } ` }
189- const cfg = perMarketResults [ base + 3 ] as unknown as { cap : bigint }
190- return { state, pos, params, cfg }
187+ const [ totalSupplyAssets , totalSupplyShares , totalBorrowAssets , , , fee ] = perMarketResults [ base ] as unknown as bigint [ ]
188+ const [ supplyShares ] = perMarketResults [ base + 1 ] as unknown as bigint [ ]
189+ const [ loanToken , , , irm ] = perMarketResults [ base + 2 ] as unknown as `0x${string } `[ ]
190+ const [ cap ] = perMarketResults [ base + 3 ] as unknown as bigint [ ]
191+ return {
192+ state : { totalSupplyAssets, totalSupplyShares, totalBorrowAssets, fee } ,
193+ pos : { supplyShares } ,
194+ params : { loanToken, irm } ,
195+ cfg : { cap } ,
196+ }
191197 } )
192198
193199 // 5. Per-market IRM + decimals (single multicall batch)
0 commit comments