Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/web/src/lib/hooks/useCallContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import { useMultichainContext } from 'state/multichain/useMultichainContext'
export function useCallContext() {
const { chainId } = useMultichainContext()
const latestBlock = useBlockNumber()
return { chainId, latestBlock }
// When latestBlock is undefined (e.g., after chain switch), use 0 to ensure multicalls still execute
// The multicall updater will handle fetching the actual latest block
return { chainId, latestBlock: latestBlock ?? 0 }
}
21 changes: 20 additions & 1 deletion apps/web/src/state/pool/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ZERO_ADDRESS } from 'constants/misc'
import { useAccount } from 'hooks/useAccount'
import { useContract } from 'hooks/useContract'
import usePrevious from 'hooks/usePrevious'
import useSelectChain from 'hooks/useSelectChain'
import { useTotalSupply } from 'hooks/useTotalSupply'
import { CallStateResult, useMultipleContractSingleData, useSingleContractMultipleData } from 'lib/hooks/multicall'
//import useBlockNumber from 'lib/hooks/useBlockNumber'
Expand All @@ -19,12 +20,14 @@ import { useParams } from 'react-router-dom'
import { useSelectActiveSmartPool } from 'state/application/hooks'
import { useStakingContract } from 'state/governance/hooks'
import { useLogs } from 'state/logs/hooks'
import { useMultichainContext } from 'state/multichain/useMultichainContext'
import { useTransactionAdder } from 'state/transactions/hooks'
import { TransactionType } from 'state/transactions/types'
import POOL_EXTENDED_ABI from 'uniswap/src/abis/pool-extended.json'
import RB_POOL_FACTORY_ABI from 'uniswap/src/abis/rb-pool-factory.json'
import RB_REGISTRY_ABI from 'uniswap/src/abis/rb-registry.json'
import { GRG } from 'uniswap/src/constants/tokens'
import { useSupportedChainId } from 'uniswap/src/features/chains/hooks/useSupportedChainId'
import { UniverseChainId } from 'uniswap/src/features/chains/types'
import { calculateGasMargin } from 'utils/calculateGasMargin'

Expand Down Expand Up @@ -162,7 +165,22 @@ export function useCreateCallback(): (
function useRegisteredPools(): PoolRegisteredLog[] | undefined {
const account = useAccount()
const registry = useRegistryContract()
const { fromBlock, toBlock } = useStartBlock(account.chainId)
const supportedConnectedChainId = useSupportedChainId(account.chainId)
const { chainId: mintChainId } = useMultichainContext()
const selectChain = useSelectChain()
useEffect(() => {
if (!mintChainId) {
return
}
if (!supportedConnectedChainId || supportedConnectedChainId !== mintChainId) {
selectChain(mintChainId).then((correctChain) => {
if (!correctChain) {
throw new Error('wallet must be connected to correct chain to swap')
}
})
}
}, [mintChainId, supportedConnectedChainId, selectChain])
const { fromBlock, toBlock } = useStartBlock(mintChainId)

// create filters for Registered events
const filter = useMemo(() => {
Expand Down Expand Up @@ -462,6 +480,7 @@ export function useStakingPools(addresses: string[] | undefined, poolIds: string
// TODO: our rpc endpoint returns multichain pools, we can render by chainId, i.e. on chain switch should update.
export function useOperatedPools(): Token[] | undefined {
const { data: poolsLogs } = useAllPoolsData()

const poolAddresses: (string | undefined)[] = useMemo(() => {
if (!poolsLogs) {
return []
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/state/webReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const interfacePersistedStateList: Array<keyof typeof interfaceReducers>
'lists',
'poolsList',
'fiatOnRampTransactions',
'logs',
]

export type InterfaceState = ReturnType<typeof interfaceReducer>
Loading