UNPKG

@openocean.finance/widget

Version:

Openocean Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.

22 lines (20 loc) 651 B
import { useQuery } from '@tanstack/react-query' import { OpenOceanService } from '../services/OpenOceanService.js' import { useSettings } from '../stores/settings/useSettings.js' const gasKey: any = { slow: 'standard', normal: 'instant', fast: 'fast', } export const useGasPrice = (chainName: string) => { const { gasPrice } = useSettings(['gasPrice']) const { data, isLoading } = useQuery({ queryKey: ['gasPrice'], queryFn: () => OpenOceanService.getGasPrice(chainName.toLowerCase()), }) const _gasPrice = data?.[gasKey[gasPrice || 'Normal']] return { gasPrice: _gasPrice && _gasPrice.maxFeePerGas, isLoading, } }