- Call usePools() when the token pair is selected. This will fetch and save the pools in
useState()
. - Pathway: usePools -> useV3SwapPools -> useAllV3Routes. This hook only needs currency in and currency out
- Further pathway: useAllV3Routes -> useBestV3TradeExactIn -> useDerivedSwapInfo
- Read currency IDs from
useSwapState
, then feed it inuseCurrency
to obtain currency
- On token change- swap/index.tsx -> useAllV3Routes
- On input amount- swap/index.tsx -> useDerivedSwapInfo -> useBestV3TradeExactIn -> useAllV3Routes
- useDerivedSwapInfo gives trade output amount, accounts and selected currencies
- useBestV3TradeExactIn() takes input amount(with currency) and output currency
- The two currencies are passed to
useAllV3Routes()
Resolved by calling useAllV3Routes in useDerivedSwapInfo(). The routes as passed as a param to useBestV3TradeExactIn()