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.

21 lines 750 B
import { useQuery } from '@tanstack/react-query'; import { OpenOceanService } from '../services/OpenOceanService.js'; import { useSettings } from '../stores/settings/useSettings.js'; const gasKey = { slow: 'standard', normal: 'instant', fast: 'fast', }; export const useGasPrice = (chainName) => { 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 || data?.gasPrice || 50000000, isLoading, }; }; //# sourceMappingURL=useGasPrice.js.map