Skip to content

Commit

Permalink
feat: extract isTradeQuoteQueryEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jun 7, 2024
1 parent f28ffdf commit c32b72b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pages/RFOX/components/Stake/Bridge/hooks/useRfoxBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,15 @@ export const useRfoxBridge: UseRfoxBridge = ({ confirmedQuote }) => {
selectAccountNumberByAccountId(state, sellAssetAccountNumberFilter),
)

const isTradeQuoteQueryEnabled = Boolean(
sellAsset && buyAsset && sellAssetAccountNumber !== undefined && wallet,
)

const tradeQuoteQuery = useQuery({
...reactQueries.swapper.arbitrumBridgeTradeQuote({
sellAsset: sellAsset!,
buyAsset: buyAsset!,
chainId: sellAsset!.chainId as EvmChainId,
sellAsset: sellAsset!, // see isTradeQuoteQueryEnabled
buyAsset: buyAsset!, // see isTradeQuoteQueryEnabled
chainId: sellAsset!.chainId as EvmChainId, // see isTradeQuoteQueryEnabled
sellAmountIncludingProtocolFeesCryptoBaseUnit: confirmedQuote.bridgeAmountCryptoBaseUnit,
affiliateBps: '0',
potentialAffiliateBps: '0',
Expand All @@ -117,7 +121,7 @@ export const useRfoxBridge: UseRfoxBridge = ({ confirmedQuote }) => {
accountNumber: sellAssetAccountNumber!,
wallet: wallet!,
}),
enabled: Boolean(sellAsset && buyAsset && sellAssetAccountNumber !== undefined && wallet),
enabled: isTradeQuoteQueryEnabled,
})

const allowanceContract = useMemo(() => {
Expand Down

0 comments on commit c32b72b

Please sign in to comment.