@@ -20,28 +20,30 @@ export function useOrdersFillability(orders: GenericOrder[]): Record<string, Ord
2020 const tokens = useMemo ( ( ) => orders . map ( ( order ) => order . inputToken . address . toLowerCase ( ) ) , [ orders ] )
2121 const { balances, allowances } = useBalancesAndAllowances ( tokens )
2222
23- return orders . reduce < Record < string , OrderFillability > > ( ( acc , order ) => {
24- const inputTokenAddress = order . inputToken . address . toLowerCase ( )
25- if ( getIsNativeToken ( chainId , inputTokenAddress ) ) {
26- acc [ order . id ] = {
27- hasEnoughBalance : true ,
28- hasEnoughAllowance : true ,
29- hasPermit : false ,
30- order,
23+ return useMemo ( ( ) => {
24+ return orders . reduce < Record < string , OrderFillability > > ( ( acc , order ) => {
25+ const inputTokenAddress = order . inputToken . address . toLowerCase ( )
26+ if ( getIsNativeToken ( chainId , inputTokenAddress ) ) {
27+ acc [ order . id ] = {
28+ hasEnoughBalance : true ,
29+ hasEnoughAllowance : true ,
30+ hasPermit : false ,
31+ order,
32+ }
33+ return acc
3134 }
32- return acc
33- }
3435
35- const balance = balances [ inputTokenAddress ]
36- const allowance = allowances ?. [ inputTokenAddress ]
36+ const balance = balances [ inputTokenAddress ]
37+ const allowance = allowances ?. [ inputTokenAddress ]
3738
38- acc [ order . id ] = {
39- hasEnoughBalance : balance ? balance . gte ( order . sellAmount ) : undefined ,
40- hasEnoughAllowance : allowance ? allowance . gte ( order . sellAmount ) : undefined ,
41- hasPermit : doesOrderHavePermit ( order ) ,
42- order,
43- }
39+ acc [ order . id ] = {
40+ hasEnoughBalance : balance ? balance . gte ( order . sellAmount ) : undefined ,
41+ hasEnoughAllowance : allowance ? allowance . gte ( order . sellAmount ) : undefined ,
42+ hasPermit : doesOrderHavePermit ( order ) ,
43+ order,
44+ }
4445
45- return acc
46- } , { } )
46+ return acc
47+ } , { } )
48+ } , [ orders , chainId , balances , allowances ] )
4749}
0 commit comments